You need to be logged in to post in the forums. If you do not have an account, please sign up first.
window.location and Opera problem
Hey all! I am trying to make my site work good on the popular browsers and came across a wierd bug that I can't understand. To keep this simple I wil make up the example. Let's say I have a button that gets clicked and runs this code:<script> document.body.style.backgroundColor = '#000000'; window.location = http://www.google.com; </script>
As far as I can tell, in modern versions of IE, Firefox, Safari and Google chrome, all of those will render the background to be black so the user sees it change black before they are redirected to google.com in the above example. For some reason, Opera is not rendering the background to be black before redirecting to google (I'm sure it runs the javascript just before it since variables in my original code do get affected).
Any ideas how I can get Opera to recognize the change and apply the affects before it goes to google? I need this change to happen BEFORE the window.location is ran so I can't use onunload.
21. May 2010, 10:05:02 (edited)
Welcome!
This is not an error. You can't see the background change because of Opera's setting to draw a page after one second. As Google loads faster than in a second, you wont be able to see your page redrawn (unless you change option to redraw instantly, but mentioned behaviour is selected by default,so your "bug" is kind of "unfixable" [without a trick like in the post below]).
You can find it in Menu O->Settings->Preferences->Advanced->Browsing (tab)->Loading.
Originally posted by OnePig2RuleThemAll:
(...) came across a wierd bug that I can't understand. (...)
For some reason, Opera is not rendering the background to be black before redirecting to google (...).
Any ideas how I can get Opera to recognize the change and apply the affects before it goes to google? I need this change to happen BEFORE the window.location is ran so I can't use onunload.
This is not an error. You can't see the background change because of Opera's setting to draw a page after one second. As Google loads faster than in a second, you wont be able to see your page redrawn (unless you change option to redraw instantly, but mentioned behaviour is selected by default,
You can find it in Menu O->Settings->Preferences->Advanced->Browsing (tab)->Loading.
<script type="text/javascript">
document.body.style.backgroundColor = "#000";
setTimeout(function () {window.location.href = "http://www.google.com";}, 0);
</script>
Tommy Olsson
Originally posted by AutisticCuckoo:
<script type="text/javascript">
document.body.style.backgroundColor = "#000";
setTimeout(function () {window.location.href = "http://www.google.com";}, 0);
</script> That's right! Just a simple trick needed
.