Pages

Search Posts

Popup Only Once - Script

Copy and paste the following script in between <head> tags to show only one popup for a visitor. Change only your website link comes here with your preferred website address.

<!--Popup Script Here-->
<script type="text/javascript">
            //get the complete queryString (url) for the popup page
            var url = document.URL;

            //use sessionStorage to control whether the page has been opened or not
            //try get the sessionStorge name, if = nothing, open page
            if (sessionStorage.getItem('visited') == null) {
                //then set a sessionStorage name and value,
                //it is important that this line appears BEFORE the window.open
                //else you will get a loop because ==null then is always true
                //at last set a sessionStorage value so it no longer ==null
                //and open window - once.
                sessionStorage.setItem("visited", "Ja");
window.open("your website link comes here",'_blank');
};
</script>
<!--Popup Script Here-->