473,320 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Changing onmouseover dymnamically

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
3 3916
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: NeoPhreak | last post by:
I am creating a menu for my site and I would like it so that when the onMouseOut even is triggered it will cause the cell of the table to fade out back to the normal color with a delay. Can...
6
by: Carla | last post by:
hi people, I have a little problem that I can't solve with css and i was wondering if you could help me. I have 4 links, I want that when I click/mouseover in the link 1, it turns to a color...
2
by: Dominic Myers | last post by:
Hi there, wondered if someone could point me to an appropriate tutorial or offer advice on the following problem? I've got a web page which uses lots of divs to position the content of the...
13
by: mike | last post by:
I have some elements that I want to change color when I mouse over them and them back on mouse off. I'd like the color to remain with "#c7d0e0" when the user clicks on them. <td...
12
by: Nico Schuyt | last post by:
Maybe a stupid question (I'm not so familiar with javascript), but: I want to change background of a paragraph or list item on mouseover. The following code works: <p...
7
by: petethebloke | last post by:
Can anyone help? I have a client who has made a "dynamic interactive map" of our city using Dreamweaver. Each map file has hotspots that pop-up a div with a little image when the mouse goes over...
3
by: Wojtek | last post by:
I have the following: <tr onMouseOver="alert('Over a row')"> and I want to modify the event to be: <tr onMouseOver="alert('Over THIS row')"> in other words reaching into the event, and...
3
by: isoquin | last post by:
I'm working with the following code, trying to change the color of the links inside the divs. While the background color and border change exactly as they're supposed to, the text/link color itself...
5
by: jeddiki | last post by:
I want to change the default background color of my select box. Here is the problem: Link to form with color select Notice in the color selector, the background color that I have given it it...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.