function test(){
alert("This message should show");
window.location.href = "http://www.google.com";
alert("This message should NOT show");
}
<href="#" onClick=test()>Click Me</a>
- Step through using Firefox(v8): The second message does NOT show.
- Step through using chrome (v15, v16): BOTH alerts show.
Chrome blows past the redirect and continues through the rest of the call stack (in this case, it finishes the onClick
) before redirecting.
- No JavaScript Errors.
- All extensions disabled.
- I'm using a blank html file with no external files loaded.
Does anyone know of a way to get chrome to execute the window.location
change immediately?