![]() |
Scoping problems between FF and Saf/Chrm
It is one thing after another.
I am testing an app in Firefox, Safari and Chrome. There are image rollovers that work in Firefox and not in Safari nor Chrome. I have run into this in the past. Code:
// this code is in a separate sourced js filepage itself to get it to work in Safari (before Chrome existed) Is there anyone who can give me some indication why and possibly how to get it to work as written in Safari and Chrome: The code that causes the error is (after the images are supposed to be preloaded) Code:
// example from the list of buttons that rollover events are applied to |
Code:
// using absolute addressing for image filesmethods I thought was successful in Safari. error text in Safari: TypeError: 'undefined' is not an object (evaluating 'document.img1.src = buttons[27].src') similar in Chrome |
Makes no sense.
You call the function thus: buttons = CALC_GLBS.preLoad(document, list); and then in the preLoad function you use a.length which of course means you are then using document.lengthSo far as I know, document.length is meaningless in any browser. The real reason it works is because you are using unneeded code. Just doing Code:
var img = [ ];Not to ask a silly question, but WHY are you doing if ( document.images )??? There are no modern browsers that don't support images. That makes less sense than people who do if ( document.getElementById )Anyway, the thing you haven't shown us in either post is where in the heck you are getting the list or array that you pass to argument b in the preLoad function. And, finally, I don't understand why you want to invoke the over function on EVERY image button just because ONE of them was rolled over. Is there really a purpose in this? |
Solved the problem
1: every image has a rollover. That is why the event is assigned to every image
There are 20 of them. 2:document.images was originally inspired by the idea that the user might have image display turned off. But your right, it is probably not necessary. But I found the problem. It was pretty simple an stupid. I converted the main page to DOCTYPE xhtml strict. That dissallows name attribute in image and form tags. So I removed the name attributes. That is why it didn't work. I converted back to xhtml transitional and add the name attributes. That fixed it. |
LOL! WOW! Talk about the left hand whacking the right one! Nice find.
|
| All times are GMT +1. The time now is 02:58 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.