$(function(){ _initjs.prevent_page_load(); }); var _initjs = (function ($, window, jQuery) { var _vars_ = {}; return { "set_vars": function (options) { $.extend(_vars_, options || {}); }, "get_vars" : function(){ return _vars_; }, "prevent_page_load" : function(){ var page_referrer = document.referrer; var _cookie_data = decodeURIComponent(_initjs.getCookie("_sdllmea")); if(_cookie_data.indexOf("logged_in") <= -1 && _cookie_data.indexOf("LeMondeFO") <= -1){ history.pushState(null, null, document.url); //window.location.href = _initjs.get_vars().baseurl; } if(page_referrer == "" || page_referrer.indexOf("home.php") != -1 || page_referrer.indexOf("login.php") != -1 || page_referrer.indexOf("dashboard.php") != -1 || page_referrer.indexOf("auth.php") != -1){ history.pushState(null, null, document.url); } history.pushState(null, null, document.url); window.addEventListener('popstate', function () { var referrer = document.referrer; history.pushState(null, null, document.url); var _cookie_data = decodeURIComponent(_initjs.getCookie("_sdllmea")); if(_cookie_data.indexOf("logged_in") != -1 && _cookie_data.indexOf("LeMondeFO") != -1){ if(referrer.indexOf("login") != -1){ //window.location.href = _initjs.get_vars().currenturl; } } }); }, "getCookie" : function(name) { var value = "; " + document.cookie; var parts = value.split("; " + name + "="); if (parts.length == 2) return parts.pop().split(";").shift(); } }; // Pass in jQuery. })(jQuery, this);