473,387 Members | 3,033 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,387 software developers and data experts.

onmouseover not working in IE7

3
Below is a snippet of code from a lengthy javascript procedure that builds a new table. It puts an "onmouseover" function call on one of the TD elements. This code works in IE6, Firefox, and Safari. But in IE7, the onmouseover function does not seem to get called when I just move the mouse over the TD. If, however, I actually click the mouse while over the TD, the function does get invoked. Because of this, it seems to me that the setup of the onmouseover event must be working (or else the function wouldn't get called at all), but for some reason just "mousing over" the TD doesn't trigger the event.

Is this some obscure IE setting? Or something else? Help, anyone? Thanks.

...
Expand|Select|Wrap|Line Numbers
  1.     nameTD.onmouseover = function() {mouseOverTeam(shortteam, this);}
  2.     nameTD.onmouseout = function() {mouseOffTeam(shortteam, this);}
...
Oct 8 '07 #1
10 11141
pbmods
5,821 Expert 4TB
Heya, Don. Welcome to TSDN!

Please use CODE tags when posting source code:

[CODE=javascript]
JavaScript code goes here.
[/CODE]
Oct 9 '07 #2
dmjpro
2,476 2GB
Below is a snippet of code from a lengthy javascript procedure that builds a new table. It puts an "onmouseover" function call on one of the TD elements. This code works in IE6, Firefox, and Safari. But in IE7, the onmouseover function does not seem to get called when I just move the mouse over the TD. If, however, I actually click the mouse while over the TD, the function does get invoked. Because of this, it seems to me that the setup of the onmouseover event must be working (or else the function wouldn't get called at all), but for some reason just "mousing over" the TD doesn't trigger the event.

Is this some obscure IE setting? Or something else? Help, anyone? Thanks.

...
Expand|Select|Wrap|Line Numbers
  1.     nameTD.onmouseover = function() {mouseOverTeam(shortteam, this);}
  2.     nameTD.onmouseout = function() {mouseOffTeam(shortteam, this);}
...
Use "addEventListner" (in case of IE) or "attachEventListener" (in case of Mozilla or Safari).
For details information do Google with it.

Debasis Jana
Oct 9 '07 #3
acoder
16,027 Expert Mod 8TB
Have a look at this article.

What does mouseOverTeam do?
Oct 9 '07 #4
acoder
16,027 Expert Mod 8TB
Use "addEventListner" (in case of IE) or "attachEventListener" (in case of Mozilla or Safari).
Not quite. That would be addEventListener for the standards-compliant browsers and attachEvent for IE.
Oct 9 '07 #5
donH
3
Thanks for this info... I apologize for neglecting to use the CODE tags... the guidelines are really very clear! My bad.
Oct 9 '07 #6
donH
3
acoder and dmjpro:

thanks to you both for the helpful responses...
I had seen another thread that talked about a problem in IE where the EventListener hadn't worked for mouseover, and so the poster had found that using the older "onmouseover" method was the only way to make it work in IE. Now I think that probably the reason that poster had a problem is the discrepancy you note between the appropriate methods for IE vs. <Rest of World>. The article you referred me to is very helpful.

To answer your question, acoder, the function that is called simply highlights or un-highlights (changes the background color) of particular cells in another table on the page. This is a local sports league site, and as you mouse over each team in the list of teams, that team's matches in a table of all matches gets highlighted.
Oct 9 '07 #7
acoder
16,027 Expert Mod 8TB
Can you show some more code or a link?
Oct 9 '07 #8
I have experienced this same problem recently. I have a JS function I wrote and have used for years that, on page load, dynamically attaches hover functions (changing the image src) to the onmouseover and onmouseout events of certain images. (A much cleaner way than littering your HTML with messy, verbose inline onmouseover/onmouseout events.) As far as I can recall, it's always worked in all browsers...until today.

For some reason, in IE7, a set of images weren't working with this function. No errors; it just seemed like the onmouseover event wasn't firing at all.

I had seen another thread that talked about a problem in IE where the EventListener hadn't worked for mouseover, and so the poster had found that using the older "onmouseover" method was the only way to make it work in IE.
I just tried this method, and sure enough, it fixed the problem. Strange.

Now I think that probably the reason that poster had a problem is the discrepancy you note between the appropriate methods for IE vs. <Rest of World>.
Here's the function I was using to attach the hover functions to the events (from dustindiaz.com ):
[HTML]
function addEvent(elm, evType, fn, useCapture) {
if (elm.addEventListener) {
elm.addEventListener(evType, fn, useCapture);
return true;
}
else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);
return r;
}
else {
elm['on' + evType] = fn;
}
}[/HTML]

Then I tried replacing it with this (supposedly more robust) addEvent function (also from dustindiaz.com):

[HTML]function addEvent( obj, type, fn ) {
if (obj.addEventListener) {
obj.addEventListener( type, fn, false );
}
else if (obj.attachEvent) {
obj["e"+type+fn] = fn;
obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
obj.attachEvent( "on"+type, obj[type+fn] );
}
else {
obj["on"+type] = obj["e"+type+fn];
}
}[/HTML]

For some reason, that also fixed the problem. Not sure why that worked better than the other addEvent(), but it did.

So this seems to confirm that attaching events in IE is not all that simple, straightforward and reliable.

Cameron
Aug 19 '08 #9
acoder
16,027 Expert Mod 8TB
Cameron, welcome to Bytes and thanks for posting.

Unfortunately, there are a lot of problems with the IE model including the loss of "this" and memory leaks. There are a lot of addEvent functions floating about that try to solve these problems.
Aug 20 '08 #10
I had this same issue. After tinkering I found the line failed in IE7 because of the double quotes. I replaced with single quotes, then it ran perfectly.

Before:
obj.attachEvent( "on"+type, obj[type+fn] );

After:
obj.attachEvent( 'on'+type, obj[type+fn] );
Oct 4 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Eqbal Z | last post by:
Hi, I have the following code, and onmouseover/onmouseout etc. does not work in netscape 4.7. <div id="divUpControl"><a href="javascript:void(0);" onMouseOver="PerformScroll(-7);"...
12
by: Epetruk | last post by:
Hi all, I want a page where the contents of a table cell are replaced with an image when the mouse moves over the cell, and the text is restored when the mouse moves out. Here's the html for the...
2
by: news.west.cox.net | last post by:
I have been writing a practice sliding div navigation script. I am finding myself in the position where I need to force a div into showing the hover behavior defined in css. So my question is...
3
by: drjackk | last post by:
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"...
2
by: MrCode2k | last post by:
Hello, Trying to do: I just want a table that I can scroll and that has fixed headers. Problem: I got it to work but when I added the onmouseover event it didn't work anymore....
7
by: MrCode2k | last post by:
Hello, Trying to do: I just want a table that I can scroll and that has fixed headers. Problem: I got it to work but when I added the onmouseover event it didn't work anymore....
1
by: den2005 | last post by:
Hi everybody, I am confused and still looking why this codes is not working. Can anyone notice or know why this code is not working? Thanks in advance. Code working: <form id="form1"...
1
by: Goutour | last post by:
Hello, I am a 2-day old Javascript developer :-) and I have a problem. I am trying to do examples I find on net about using onmouse events. I found a javascript that generates flying objects, and I...
3
by: pmadhu512 | last post by:
hi below code is working in the IE6 and mozilla but not working IE7.when i moving the mouse to the block the popup getting closed could you please help me how to resolve this problem ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.