jqueryajaxhtmlpopstate

oppopstate not trigger in firefox and ie11


I was looking around for some time into example made by Sebastian Sulinki

here' demo - http://html5-history-pushstate.ssdtutorials.com/ It is perfect, but it seems that window.onpopstate = function(){

does not work on document ready or window load in firefox and interner explorer 11 and 10 It does trigger on other browsers.

I can't demonstrate in on my server because it wont work(demo) on not domain script works only on domain.com/ will not work server.com/folder/ So sorry about that, I dont have any free domain.

But if anyone would like to invastigate it a bit more, just download it and try on localhost/ (not lower folder but main directory) or on some domain

Then easy way to check it is to add console.log("this url is " + url); to this fragment of script

load: function(url) {
    url = url === '/' ? '/ygwyg' : url;
    jQuery.getJSON(url, {
        ajax: 1
    }, function(data) {

        jQuery.each(data, function(k, v) {
            $('#' + k + ' section').fadeOut(200, function() {
                $(this).replaceWith($(v).hide().show());
                console.log(url)
            });
        });
    });

},

When you'll open website on chrome it will show url at start, but on FF and IE it will show nothing until you'll press #navigation a button then script trigger.

Thanks for time used and any anwsers, tips, info :)

EDIT: I found out here(link under) about that will not trigger - but why? any solutions? http://blog.teamtreehouse.com/getting-started-with-the-history-api


Solution

  • I found solution after some time

        setTimeout(function() {
            $(window).trigger('popstate');
        }, 1);
    

    Hope it'll help someone inf future