Forum Moderators: open

Message Too Old, No Replies

Safari doesn't like my javascript

         

dementia

10:47 pm on Feb 17, 2006 (gmt 0)

10+ Year Member



This is a pretty simple javascript that shows or hides a div, depending on if you click on a link or not. However, Safari/Konqueror will load the .js file, and it works, but while it doesn't throw any errors, it also doesn't load the function form_popup.

Any ideas or even pointers a site listing the safari javascript quirks would be appreciated. Thanks in advance.

[edited by: DrDoc at 12:56 am (utc) on Feb. 18, 2006]
[edit reason] No URLs, thanks. See TOS [WebmasterWorld.com] [/edit]

whoisgregg

11:32 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com], dementia!

First, the TOS [webmasterworld.com] doesn't allow linking to your own sites. A moderator will be by shortly to snip those URLs. The approach here is to reduce down problematic code until you've identified the specific bit that is causing the problem.

Second, I went ahead and did that with your script. :) You currently use this method to loop through the nodeList of <a> tags:

for(i in anchor_list)

Inside that loop, I added a little bit of code so I could ensure that was working:

anchor_list[i].style.background='#cccccc';

On opening the page, the links all kept their default background, so the assignment of the function to the onclick of each <a> tag wasn't even occurring.

Now, I've not seen a loop that looked like yours (probably because of my inexperience), so I replaced it with what I typically use:

for(var i=0; i<anchor_list.length; i++)

And, that change makes your script work in both Safari and Mac Firefox. :)

dementia

12:56 am on Feb 18, 2006 (gmt 0)

10+ Year Member



My apologies. That's what I get for skimming the TOS. :(

Ah! I am just starting out and got that bit from a friend, so I am assuming Safari doesn't much like his method of looping.

Thank you so much!