browserstate / history.js

History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports jQuery, MooTools and Prototype. For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.
http://browserstate.github.com/history.js/demo/
Other
10.75k stars 1.35k forks source link

Using window.onload leads to conflicts #302

Open x-yuri opened 11 years ago

x-yuri commented 11 years ago

I particularly have an issue with history.js, overwriting dropfile's event handler.

x-yuri commented 11 years ago

At least call the previous handler. This is how I resolved the problem:

<script src="/js/dropfile.js"></script>
<script>var windowOnLoad1 = window.onload;</script>
<script src="/js/native.history.js"></script>
<script>
    var windowOnLoad2 = window.onload;
    if (windowOnLoad1 && windowOnLoad2 && windowOnLoad1 != windowOnLoad2)
        window.onload = function() {
            windowOnLoad1 && windowOnLoad1.apply(this, arguments);
            windowOnLoad2 && windowOnLoad2.apply(this, arguments);
        };
</script>