Forum Moderators: open

Message Too Old, No Replies

Update to IE6, Moziall etc. for MouseOver in an ImageMap

         

ksoltau

3:25 pm on May 18, 2004 (gmt 0)

10+ Year Member



Hi,
I am a bloody beginner with JS and I am sorry, when not picking an already posted message to solve my problem. ( I 've searched, but I did not find the appr. answer, however)

I use a JS to have a MouseOver in an Image Map. (When moving the mouse over a certain area ('area') a text should be displayed in a certain area ('descr'). To achieve that I use a JS-function

*****************************************************
ns = (document.layers)? true:false
ie = (document.all)? true:false

function layerWrite(text) {
if (ns) {
var lyr = document.layers['descr'].document
lyr.open()
lyr.write(text)
lyr.close()
}
else if (ie) document.all['descr'].innerHTML = text
}
********************************************************

All works fine with IE5, but from Version IE6 and Mozilla and Netscape nothing works!

I assume there is something wrong with the way I use the document-object .....

May someone help me or give a hint. I have tried different things already, but didn't find an apporpriate exampl yet.

Sorry - if my problem is trivial, but I got stuck and really need that :-(

Thanks

k soltau

Bernard Marx

4:38 pm on May 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The code you are using is badly outdated. Not your fault, the Web is full of this stuff.

To cover ALL browsers ver 5+ (arguably everything, unless you get good money to support Netscape 4 / IE 4), your function could simply read:

[pre]
function layerWrite(text)
{
document.getElementById('descr').innerHTML = text
}
[/pre]

Your browser sniffers should be:


ns4 = (document.layers)?true:false
moz = (document.getElementById &&!document.all)?true:false
IE5 = (document.getElementById && document.all)?true:false // + upwards
IE4 = (document.all &&!document.getElementById))?true:false

You don't need them here (apart from to prevent v4s from being used)

ksoltau

6:44 am on May 19, 2004 (gmt 0)

10+ Year Member



Thanks a lot from a bloody beginner :-)

ksoltau