470,614 Members | 1,463 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,614 developers. It's quick & easy.

accessing <area> attributes in Mozilla?

I would like to be able to dynamically change the attributes of an <area>
element in an image map. The following works in IE 6 and Opera 7:

<map name="Map1">
<area shape="rect" coords="10,10,100,50" href="foo.html" id="area1">
</map>
....
<script>
document.area1.href = "bar.html";
</script>

but it doesn't work in Mozilla 1.4. I tried using name="area1", but that
didn't work either. Is there any way to referrence the attributes of an
<area> tag in Mozilla?

thanks,
Gabe
Jul 20 '05 #1
2 1918


Gabe Moothart wrote:
I would like to be able to dynamically change the attributes of an <area>
element in an image map. The following works in IE 6 and Opera 7:

<map name="Map1">
<area shape="rect" coords="10,10,100,50" href="foo.html" id="area1">
</map>
...
<script>
document.area1.href = "bar.html";
</script>

but it doesn't work in Mozilla 1.4. I tried using name="area1", but that
didn't work either. Is there any way to referrence the attributes of an
<area> tag in Mozilla?


You need to learn how to access an element with an id attribute set with
script:
var area;
if (document.getElementById) {
area = document.getElementById('area1');
if (area) {
area.href = 'bar.html';
}
}
That works with IE5+, Netscape 6+, Mozilla, Opera 7 and any other
browser implementing the W3C DOM Core and HTML

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Lee
Gabe Moothart said:

I would like to be able to dynamically change the attributes of an <area>
element in an image map. The following works in IE 6 and Opera 7:

<map name="Map1">
<area shape="rect" coords="10,10,100,50" href="foo.html" id="area1">
</map>
...
<script>
document.area1.href = "bar.html";
</script>

but it doesn't work in Mozilla 1.4. I tried using name="area1", but that
didn't work either. Is there any way to referrence the attributes of an
<area> tag in Mozilla?


The correct way to referrence it in any modern browser:
document.getElementById('area1').href

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

61 posts views Thread by Toby Austin | last post: by
1 post views Thread by Brad | last post: by
11 posts views Thread by Les Paul | last post: by
5 posts views Thread by Garmt de Vries | last post: by
6 posts views Thread by Tony | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.