function init()

in src/modules/controllers/history.js [6:30]


function init() {
    window.addEventListener('popstate', onPopState);

    document.getElementById('viewer').addEventListener('load', function(e) {

        try {
            var iframeLocation = e.target.contentWindow.location;
            e.target.contentWindow.location.href; //Requied to trigger Same origin warnings
        } catch(e) {

            if (window._previewEnv === 'preview') {
                errorController.showError('This could not be detected as a Guardian page, some features will be unavailable');
            }

            return;
        }

        errorController.hideError();
        //If we get a browser error page, then don't replaceLocationHistory
        if (iframeLocation.origin !== 'null' || iframeLocation.protocol.indexOf('http') !== -1) {
            //Needs to be replace (not push) as the iframe has added it's own history entry (shakes fist).
            replaceLocationHistory(iframeLocation);
        }
    });
}