Redirect into a hash-style URL causes a reload in IE

1,686 views
Skip to first unread message

Andy

unread,
Nov 5, 2010, 10:12:57 AM11/5/10
to Google Web Toolkit
We just ran into this and hopefully if you come across this I can save
you from having to go through the same painful day of debugging that I
just experienced.

The issue basically works like this:

Suppose you have a login page at /login and after a successful login,
you redirect into your gwt application at something like /app#token.
When you try to navigate from that page using a Hyperlink which sets
location.hash, it will cause the page to reload instead of navigating.

The reason for this is pretty complicated and I can't say I fully
understand it. It seems to be a combination of 1) a bug in IE, 2) the
HistoryImplIE6 timer, and 3) a timing issue.

It only happened occasionally until I put a 1s sleep in my bootstrap
page. The it happened everytime. Again, you have to come from a 302
redirect into a hash token for this to happen.

Our specific case was actually redirecting query style URLs like /app?
token=foo -> /app#foo

Other developers have run into this before. You can read more about it
here:

http://stackoverflow.com/questions/1985056/response-redirect-with-a-fragment-identifier-causes-unexpected-refresh-when-later

and here:

http://stackoverflow.com/questions/2602260/javascript-location-hash-refreshing-in-ie/3804661#3804661

That second link contains the fix that I used.

I added:

window.location.hash = window.location.hash;

in a script tag at the top of my bootstrap page. I only do this for IE
even though it's probably safe for all browsers.

Gal Dolber

unread,
Nov 5, 2010, 2:40:40 PM11/5/10
to google-we...@googlegroups.com
Thanks, I didn't even try to find a solution.
It's incredible how I hate ie more and more every day


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--
Guit: Elegant, beautiful, modular and *production ready* gwt applications.

http://code.google.com/p/guit/




Reply all
Reply to author
Forward
0 new messages