Forum Moderators: travelin cat
I am having problems writing some simple javascript functions.
First Problem:
I want to be able to show / hide images on the screen when you click on a link
My code:
function show() {
document.getElementById('image').style.setProperty('visibility', 'visible');
}
This works fine on my PC but not on MAC OS9 running IE5.
What do I need to change to get this to work.
Second Problem:
Along the same lines I would like to be able to change the text colours
My code:
function changecolour() {
document.getElementById('textid').style.setProperty('fill', '#FF9900');
}
Again this works on PC but not the MAC ... can you help.
Thanks in advance,
Matthew
function show(image) {
document.getElementById(image).style.visibility = "visible";
}
function hide(image) {
document.getElementById(image).style.visibility = "hidden";
}
<div id="img1"><img src="image.jpg"></div>
<a href="javascript:show('img1')">show</a> -
<a href="javascript:hide('img1')">hide</a>
----
2.
<script language="JavaScript">
function changecolor(text) {
document.getElementById(text).style.color = "#FF9900";
}
<div id="text1">Text to change</div>
<a href="javascript:changecolor('text1')">color</a>
---
Both works with:
- MacOS9 / IE 5.1.4
- MacOS 10.2.6 / IE 5.2 + Safari 1.0
Sorry, I should have offered more information in my original post.
I have created an SVG image which is embedded in an ASP page. The ASP page has a form which allows the end user to control the SVG graphic layout i.e. change colours, show/hide grouped objects, change text and fonts and so on.
Therefore using a show / hide layer idea is not what I am after. I have everything working well on my PC but just cannot crack things for the MAC.
The SVG object looks something like this:
<svg>
<g id="Object1" style="visibility:hidden;">
<!-- Object path to go here -->
</g>
</svg>
Then in the ASP page I have some Javascript that goes something like:
function show(){
var svgobj;
var svgdoc = document.SVGObject.getSVGDocument();
svgobj = svgdoc.getElementById('Object1');
svgstyle = svgobj.getStyle();
svgstyle.setProperty('visibility', 'visible');
}
Would be greatful if you could shed some light on this.
Thanks,
Matthew
Go to [adobe.com...] you can download a MAC SVG viewer. Basically SVG is short for Scalable Vector Graphics and is a relatively new W3C standard for web graphics.
The problem is not that the MAC cannot read the SVG rather I cannot get the javascript to work to show and hide objects within the SVG as I can with the PC.
Thanks for your help anyway.
Matt
Sorry for being unclear. I know what svg is and that it is supported on Mac - however, i never saw the svg /g tags and i don't think that the getProperty / setProperty functions and the svg object are supported on mac. This much sound like Windows' own DOM stuff which only is supported on Windows' MSIE.
I tried something like this instead but to no avail:
document.getElementById("Object").style = "visible"; or
document.getElementById("Object").style = "hidden";
Any ideas how you would hide / show a normal graphic on a page?
Look forward to any help you can give.
Thanks,
Matthew