Re: browser differences, IE, FF, and Opera
- From: Lasse Reichstein Nielsen <lrn.unread@xxxxxxxxx>
- Date: Fri, 06 Mar 2009 17:59:06 +0100
ccc31807 <cartercc@xxxxxxxxx> writes:
function clear()
{
var len = history.length;
history.go(-len);
window.location.href = 'myotherURL.com';
}
window.onunload = clear();
Funny thing is that in IE and FF the location gets set to
myotherURL.com as it should but the history doesn't clear, while in
Opera the history clears but the location doesn't get reset.
I'm guessing that the problem is that both history.go and
window.location.href-assignment are navigations. You can only navigate
away from a page once. Whether it's the first or the second navigation
that takes effect appears to differ, but you can't have both.
What gives, and is there any way I can have both behaviors in IE, FF,
and Opera?
If there is, it's a bug that should be fixed, so not something you should
depend on.
The problem is that the behavior you want can also be used destructively.
Executing the script
history.go(-history.length);
window.location.href="yaddayadda.html";
successfully will erase your browsing history for that tab/window.
It might not be much, but it's still a loss.
Instead you could run your entire application inside a full-page
frame, and from the page containing the frame you can clear the
contents and navigate away from the page. It might be closer to
what you want, and possible.
Or, you could have a login page that sets a cookie, and an on-load
event on all following pages that check for that cookie and does
history.go(-1) if it isn't set.
Then on logout (onunload perhaps) you clear the cookie and do
history.go(-1), which moves back through history until it meets
the login page again.
These are just guesses, I have no idea whether it will work in
practice :)
/L
--
Lasse Reichstein Holst Nielsen
'Javascript frameworks is a disruptive technology'
.
- Follow-Ups:
- Re: browser differences, IE, FF, and Opera
- From: ccc31807
- Re: browser differences, IE, FF, and Opera
- References:
- browser differences, IE, FF, and Opera
- From: ccc31807
- browser differences, IE, FF, and Opera
- Prev by Date: Re: browser differences, IE, FF, and Opera
- Next by Date: Re: javascript alert freezes the screen
- Previous by thread: Re: browser differences, IE, FF, and Opera
- Next by thread: Re: browser differences, IE, FF, and Opera
- Index(es):
Relevant Pages
|