dimanche 26 juin 2016

How to modify existing script to delay popup on blogger?

I have a script below that creates a popup for users to provide their email addresses. It works fine. I tried to use setTimeout() to delay the popup but couldn't get it right. Please advise how my script below should be modified. Many thanks! (I apologize for the messy format.)

Blogger myimmigrationlawyer.blogspot.com

src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjpBEVvMKAjMp17STaN3dK97UOM5Oo_2UKKvvZBaykXggl3Q1x2E5Vo78y0Ij8apjSkBEVnxPCn_bqC97ao_t9pwtO-2vGC-sE9OPp7gGUt63HMmAi7UV4k2wKSz9Xuybews9Jvi4xbrGZ/s1600/Subscribe+Via+Email.PNG" />
<div id="description">

<img alt="email" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1ytRcIGT0jJG3eyEfn7ebJhAeFDExaQbIlCgnKm8hbNKaIto7ZKjJXB-arKVD76wb4p9PCswCnfltVe0RWqkh55YH5SZMLuE-o8_vzOs5uDFxglYjvpDep9Zq4J4BcpirHMMU8RfHV3eW/s1600/Mail.PNG" /> <strong><b>Get instant updates on immigration matters...</b></strong></div>
<form action="http://feedburner.google.com/fb/a/mailverify" method="post" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=blogspot/BVMU', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true" target="popupwindow">

<input name="email" placeholder="Enter Your Email..." required="required" type="text" /><input name="uri" type="hidden" value="blogspot/BVMU" /><input name="loc" type="hidden" value="en_US" />

<div class="button">

    <input type="submit" value="Subscribe" /></div>

    </form>

</div>

<div class="btntFollowFooter">

    Delivered by <a href="http://feedburner.google.com/"       target="_blank">FeedBurner</a> | powered by <a     href="http://www.blogtipsntricks.com/" rel="dofollow" target="_blank">blogtipsntricks</a></div>

</div>

</div>


<script 

    src="http://yourjavascript.com/24315621361/jquery.cookie.js"     type="text/javascript">

</script>


<script type="text/javascript">

     var popupStatus = 0;

//this code will load popup with jQuery magic!

function loadPopup(){

    //loads popup only if it is disabled

    if(popupStatus==0){

        $("#backgroundPopup").fadeIn("slow");

        $("#popupContact").fadeIn("slow");

        popupStatus = 1;

    }

}



//This code will disable popup when click on x!

function disablePopup(){

    //disables popup only if it is enabled

    if(popupStatus==1){

        $("#backgroundPopup").fadeOut("slow");

        $("#popupContact").fadeOut("slow");

        popupStatus = 0;

    }

}



//this code will center popup

function centerPopup(){

    //request data for centering

    var windowWidth = document.documentElement.clientWidth;

    var windowHeight = document.documentElement.clientHeight;

    var popupHeight = $("#popupContact").height();

    var popupWidth = $("#popupContact").width();

    //centering

    $("#popupContact").css({

        "position": "absolute",

        "top": windowHeight/2-popupHeight/2,

        "left": windowWidth/2-popupWidth/2

    });

    //only need force for IE6  

    $("#backgroundPopup").css({

        "height": windowHeight

    });



}

//CONTROLLING EVENTS IN jQuery

$(document).ready(function(){

    if ($.cookie("anewsletter") != 1) {  

        //centering with css


       centerPopup();

        //load popup






     loadPopup(); 

    }      

    //CLOSING POPUP

    //Click the x event!

    $("#popupContactClose").click(function(){

        disablePopup();

        $.cookie("anewsletter", "1", { expires: 2 });

    });

    //Press Escape event!

    $(document).keypress(function(e){

        if(e.keyCode==27 && popupStatus==1){

            disablePopup();

            $.cookie("anewsletter", "1", { expires: 7 });

        }

    });



});</script>

Aucun commentaire:

Enregistrer un commentaire