'Pageshow event in Firefox not firing

I am trying to find a cross-browser way to detect pageshow event, because in Firefox it doesn't fire every time. I am using this code to register pageshow callback:

 $(window).on('pageshow', callback);

This works great in Chrome, but in Firefox, callback is called only every third time after page refresh, and I suspect this happens due to caching. Now, similar thing happens with document load event in Firefox, but I found a way around:

var intervalCheck = setInterval(function() {
                if (document.readyState === "complete") {
                    clearInterval(intervalCheck);
                    callback();
                }
            }, 10);

This works great, is there maybe a similar thing for pageshow event ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source