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

Changing onmouseover dymnamically

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

Jan 9 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
dr*****@swbell.net 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;
}
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 9 '06 #2

P: n/a
On Sun, 08 Jan 2006 23:38:44 -0500, Randy Webb
<Hi************@aol.com> wrote:
dr*****@swbell.net 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;
}


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

Jan 12 '06 #3

P: n/a
dr*****@swbell.net said the following on 1/11/2006 10:40 PM:
On Sun, 08 Jan 2006 23:38:44 -0500, Randy Webb
<Hi************@aol.com> wrote:

dr*****@swbell.net 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;
}

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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Jan 12 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.