473,387 Members | 1,574 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.

Problems with onmouseover in IE 6.0

Hi there, my problem seems pretty straight forward I think, possibly I just don't know how to handle IE 6.0 yet. I'm trying to keep my JavaScript unobtrusive to my XHTML and am setting my mouse overs dynamically onload. It goes something like this:
Expand|Select|Wrap|Line Numbers
  1.     for (i = 0; i < menuArray.length; i++){
  2.             var mouseRoll = document.getElementById(menuArray[i]);
  3.             var funcName = "menuRoll('" + menuArray[i] + "');";
  4.             mouseRoll.setAttribute("onmouseover", funcName);
  5.     }
  6.  
menuArray is an array that contains all the id's of the anchors I want to put mouseovers on and has a length of 0-6. menuRoll is the function I want to call onmouseover. I know that setAttribute is buggy in IE 6.0 so I tried this:
Expand|Select|Wrap|Line Numbers
  1.             for (i = 0; i < menuArray.length; i++){
  2.             var mouseRoll = document.getElementById(menuArray[i]);
  3.             var funcName = "'" + menuArray[i] + "'";
  4.             mouseRoll.onmouseover = function(){menuRoll(funcName)}
  5.                         }
  6.  
this managed to fire the menuRoll function but always sends the value of the last string in the menuArray both in IE 6.0 and FF.
where do i go from here?

cheers
Josh W
Jun 3 '07 #1
1 1289
mrhoo
428 256MB
The easiest cross browser strategy is to get a
reference to the element that triggered the event from the event itself,
at the beginning of your event handlers:
Expand|Select|Wrap|Line Numbers
  1. var L=menuArray.length;
  2. for(var i = 0; i < L; i++){
  3.     document.getElementById(menuArray[i]).onmouseover = menuRoll;
  4. }
Expand|Select|Wrap|Line Numbers
  1. function menuRoll(e){
  2.     e=e? e.target: event.srcElement;
  3.     // e now is a reference to the element that called menuRoll
  4.  
  5. }
Jun 3 '07 #2

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

Similar topics

4
by: Nigel Gomm | last post by:
i have a problem with Mac browsers. As can be seen from the following HTML fragment i have some images that should, when clicked, open up a <div>. This works fine on all window's browsers (that...
2
by: cbjewelz | last post by:
Hey all. So I'm having problems with cross browser alignments. I'm looking at Safari and Mozilla Firefox. I develop in Safari and so it looks perfect there however in Firefox my vertical...
2
by: funkiejunkie | last post by:
Hello all, I posted a thread a while ago and was told to include the code so here it is. I still dont really get CSS, everything I have done has been blagged because I cant be bothered to read...
7
by: deste | last post by:
Hi folks! I've got a problem with javascript and DOM. I want to create a simple "intelligent" <table>, inside a data-form. I'd like to do: - Change color of any <tron onMouseOver DOM event; -...
34
by: aljamala | last post by:
I keep getting this error for the given code region (it actually highlights the line with the body tag): line 42 column 1 - Warning: <trisn't allowed in <bodyelements </head> <body...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.