This is driving me insane, this is HTML code.
<html>
<head>
<script>
function init() {
console.log("fire once");
window.onhashchange = function() {
console.log(location.hash);
}
}
</script>
</head>
<body onload="init();">
<a href="#t1">T1</a>
<a href="#t2">T2</a>
</body>
</html>
Steps to reproduce bug (bug I believe), open console, click T1, click T2, click back, click back… on Firefox this is console output (I have append mouse action inside []).
[load]
fire once
[click T1]
#t1
[click T2]
#t2
[click back]
#t1
[click back]
(an empty string)
On Google Chrome 14.0.835.202 (tested on Ubuntu and Windows XP), this is output.
[load]
fire once
[click T1]
#t1
[click T2]
#t2
[click back]
fire once
#t1
#t2
#t1
[click back]
fire once
#t1
#t2
#t1
(an empty line)
Safari does not reproduce this bug, so maybe this is V8 bug? how the hell did Google Chrome went through two years with this bug? and most importantly how do I prevent it?
Thanks everyone.
The onload event is not being fired again. You’re seeing the output from the time when you clicked T1 and T2. Chrome does not refresh the console when you navigate the same page via clicking # links or the back button.
EDIT: Okay, I may have misunderstood by what you meant by the []. If the final output you get in the console is
then this appears to have been fixed in the latest Dev version 17 I checked on (although it also works fine on an ancient Chromium 12 I had lying around). I haven’t checked on the stable Chrome 15.
If instead, you mean that the final output in the console is only the last five lines of that, then the reason is as I gave in my answer.