By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,567 Members | 1,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,567 IT Pros & Developers. It's quick & easy.

accessing <area> attributes in Mozilla?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a


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

P: n/a
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.