User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,160 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,308 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1864 | Replies: 4
Reply
Join Date: Aug 2007
Posts: 2
Reputation: epod@ucla.edu is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
epod@ucla.edu epod@ucla.edu is offline Offline
Newbie Poster

Problem with window.location in Safari (mac only)

  #1  
Aug 23rd, 2007
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.

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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Posts: 2,510
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 103
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

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

  #2  
Aug 23rd, 2007
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.
Daylight-saving time uses more gasoline
Reply With Quote  
Join Date: Aug 2007
Posts: 2
Reputation: epod@ucla.edu is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
epod@ucla.edu epod@ucla.edu is offline Offline
Newbie Poster

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

  #3  
Aug 23rd, 2007
Originally Posted by MidiMagic View Post
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.
Reply With Quote  
Join Date: Jan 2007
Posts: 2,510
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 103
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

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

  #4  
Aug 23rd, 2007
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 23rd, 2007 at 11:45 pm.
Daylight-saving time uses more gasoline
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,767
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 329
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

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

  #5  
Aug 24th, 2007
> 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.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:26 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC