944,187 Members | Top Members by Rank

Ad:
Aug 23rd, 2007
0

Problem with window.location in Safari (mac only)

Expand Post »
I have a web site where we have a few elements that call javascript functions on the onclick. The javascript functions will do some processing and what not and eventually call a window.location to change the url. In Safari (mac only) window.location is not being processed until the current page is fully loaded.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. window.location = 'http://google.com';

This is hard to reproduce because most sites load up pretty fast, but on our site we have different tracking / logging pixels that sometimes take a while for the page to 'fully' load so if I click any of these elements that do a window.location call, the page will not change until the current page is loaded.

I haven't been able to find a way around this. This works fine in IE, Firefox, and Safari for Windows but not on the Mac version. I also thought okay maybe I could just stop the page from loading, but I haven't found an equivalent for window.stop() in Safari.

Any help is greatly appreciated.

Thanks,
Victor
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
epod@ucla.edu is offline Offline
2 posts
since Aug 2007
Aug 23rd, 2007
0

Re: Problem with window.location in Safari (mac only)

Some browsers do not do ANY processing until the download of the initial page is complete. This is beyond your control. You need to allow for this when designing your pages.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
Aug 24th, 2007
0

Re: Problem with window.location in Safari (mac only)

Click to Expand / Collapse  Quote originally posted by MidiMagic ...
Some browsers do not do ANY processing until the download of the initial page is complete. This is beyond your control. You need to allow for this when designing your pages.
That I can understand but all the other javascript will run fine on the page. For example I have script hide/show divs when clicked, to modify cookies, etc. All that gets run, it's just the window.location call won't get executed until the page is fully loaded.

I've been trying to figure out ways around it, but nothing has come to mind yet. We have a search box that dynamically builds your url depending on what you entered, and what check boxes you checked, but clicking the search button won't replace the window.location because of the page not fully loaded.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
epod@ucla.edu is offline Offline
2 posts
since Aug 2007
Aug 24th, 2007
0

Re: Problem with window.location in Safari (mac only)

The only thing I can think of is having the script load some of the time-consuming stuff with a delayed call, after doing the window sizing.

I had to deal with timing issues like this here:

http://www.daniweb.com/forums/thread85060.html
Last edited by MidiMagic; Aug 24th, 2007 at 12:45 am.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
Aug 24th, 2007
0

Re: Problem with window.location in Safari (mac only)

> http://www.daniweb.com/forums/thread85060.html
I think this thread is turning out to be a kind of reference to all those beaten up by timing issues... ;-)

And BTW, its actually window.location.href = 'http://www.google.com' and not window.location = 'http://www.google.com' since location is an object _not_ of type String.
Super Moderator
Featured Poster
Reputation Points: 3241
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: How to restrict the entry of alphabets in a textbox using javascript...?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: what is active X?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC