Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Image | Q1337 [ previous next ]

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/';
        ....
    }
    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?'

©2018 Martin Webb