devote / HTML5-History-API

HTML5 History API expansion for browsers not supporting pushState, replaceState
http://spb-piksel.ru
MIT License
1.02k stars 182 forks source link

window.onpopstate fires twice in Safari 8.0 #69

Closed tonovotny closed 9 years ago

tonovotny commented 9 years ago

Hi, window.onpopstate handler function is fired twice in Safari 8.0. Once by browser and once by history.js code.

Simple test in console:

window.onpopstate = function() { console.log('tomas') };

I will try to elaborate this further..

Tomas

devote commented 9 years ago

Yes, I struggled with this problem in previous versions of Safari, I found a hack. Now apparently the hack does not work. :(

I'll think about it. But I recommend to use the method window.addEventListener:

window.addEventListener('popstate', function() {
  console.log('tomas');
}, false);
devote commented 9 years ago

The bug has been corrected, test the changes. Thank you!

tonovotny commented 9 years ago

Yep! Fixed ;)

Thank you for the changes and all the work!

Tomas