Changing onmouseover dymnamically

D

drjackk

Hello,

I'm trying to change the onmouseover event dynamically.

This sets-up the initial onmouseover event:

<a href="home.html"> <img border="0" id="img22"
src="images/home1.jpg" height="15" width="85" alt="Home"
onmouseover="FP_swapImg(1,0,/*id*/'img22',/*url*/'images/home2.jpg')"</a>

Here I'm changing the image and trying to disable the onmouseover
event:

<script type="text/javascript">
if (bHome==0) {
FP_swapImg(1,0,/*id*/'img22',/*url*/'images/contact1.jpg');
document.write ('<div id="img22" onmouseover=""><\/div>');
}
</script>

This script works with Mozilla but not with IE.
Any recommendations or suggestions?

Thanks for your help,
Richard
 
R

Randy Webb

(e-mail address removed) said the following on 1/8/2006 11:23 PM:
Hello,

I'm trying to change the onmouseover event dynamically.

This sets-up the initial onmouseover event:

<a href="home.html"> <img border="0" id="img22"
src="images/home1.jpg" height="15" width="85" alt="Home"
onmouseover="FP_swapImg(1,0,/*id*/'img22',/*url*/'images/home2.jpg')"</a>

Is FP_swapImg a Front Page generated function?

If all you are wanting to do is change the onmouseover then reset it:

onmouseover="this.src='images/home2.jpg';this.onmouseover=null"

If you are intent on using the FP function then you have the id of the
image, you can set its onmouseover to null there:

function FP_swapImg(p1,p2,imageID,imageNewSrc){
//existing code
document.getElementById(imageID).onmouseover = null;
}
 
D

drjackk

(e-mail address removed) said the following on 1/8/2006 11:23 PM:

Is FP_swapImg a Front Page generated function?

If all you are wanting to do is change the onmouseover then reset it:

onmouseover="this.src='images/home2.jpg';this.onmouseover=null"

If you are intent on using the FP function then you have the id of the
image, you can set its onmouseover to null there:

function FP_swapImg(p1,p2,imageID,imageNewSrc){
//existing code
document.getElementById(imageID).onmouseover = null;
}

Thanks for the info. It did the trick.

I uses this line for IE to work correctly:
document.getElementById(imageID).onmouseover = null;

And used this line for Mozilla to work to correctly:
document.write ('<div id="imageID" onmouseover=null>');

I'm not sure why. Differences in the browsers I presume. But I've got
it working now.

Does anyone have any recommendations on good documentation (web sites,
books, etc.) that discribes the document and object properties. I
spend a lot of time trying to find a particular property for an object
or document. I've got a few properties figured out, but a good
document sure would be nice.

Have a good nite,
Richard
 
R

Randy Webb

(e-mail address removed) said the following on 1/11/2006 10:40 PM:
Thanks for the info. It did the trick.

I uses this line for IE to work correctly:
document.getElementById(imageID).onmouseover = null;

And used this line for Mozilla to work to correctly:
document.write ('<div id="imageID" onmouseover=null>');

How are you determining whether it is Mozilla or IE? I hope it's not via
the userAgent string? The first should work in both IE and Mozilla and
testing shows that it does so there is no need to try to figure out the
browser.

Also, using document.write after the page loads is a disaster in the
making as it wipes out the current page and replaces it with the new
content.
I'm not sure why. Differences in the browsers I presume. But I've got
it working now.

Does anyone have any recommendations on good documentation (web sites,
books, etc.) that discribes the document and object properties. I
spend a lot of time trying to find a particular property for an object
or document. I've got a few properties figured out, but a good
document sure would be nice.

To date, the best documentation I have found are the browsers
themselves. The archives for this group is also a good place to research.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top