Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1337 How can the 'usemap' property of the image object be dynamically assigned?

irt.org | Knowledge Base | JavaScript | Image | Q1337 [ previous next ]

Q1337 How can the 'usemap' property of the image object be dynamically assigned?

Everything in Internet Explorer is dynamic, so in principle you could do something like:

<map id="myMap">
...
</map>

<script language="JavaScript"><!--
if (document.all)
    document.all.myMap.innerHTML='<area.....><area...>';
//--></script>

A Netscape compatible solution would be to use javascript urls in the hrefs and change where they go to instead:

<script language="JavaScript"><!--
function url(link) {
    // example condition:
    if (navigator.appName == 'Microsoft Internet Explorer') {
        if (link == 1) location.href = 'http://www.irt.org/index.htm';
        ....
    }
    else {
        if (link == 1) location.href = 'http://www.irt.org/whatsnew.htm';
        ....
    }
}
//--></script>

<map>
<area shape="rect" coords="0,0,400,25"     href="javascript:url(1)">
<area shape="rect" coords="0,25,25,375"    href="javascript:url(2)">
<area shape="rect" coords="25,25,174,375"  href="javascript:url(3)">
<area shape="rect" coords="175,25,225,375" href="javascript:url(4)">
<area shape="rect" coords="225,25,375,375" href="javascript:url(5)">
<area shape="rect" coords="375,25,400,375" href="javascript:url(6)">
<area shape="rect" coords="0,375,400,400"  href="javascript:url(7)">
</map>

Also see the answer to FAQ 336.

Feedback on 'Q1337 How can the 'usemap' property of the image object be dynamically assigned?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.