Search code examples
jquerypopupsocial-networking

jquery Pop up box on page load & auto close after timeout


Hi i want a pop up and disable all page(on which the pop up is) and show facebook fanpage like button or social share buttons and make it compulsory like/share to every visitor or else he need to wait for some 15-20 secs to view main page


Solution

  • You need to do the following. See what I did and implement it. the setInterval will run every 15 seconds, but the to do list in the interval is wrapped with a if statement, so it will only apply it once.

    <html>
    <head>
    <script src='path/to/jquery.js'></script>
    <style>
    #popup {
     add you styling
    }
    </style>
    </head>
    
    <body>
    
    <div id='popup'>popup content</div>
    
    <script>
    $(document).ready(function(){
    $('#popup').fadeIn();
    
    var repeatPopUp = 0;
    
    setInterval(function(){
    
    if(repeatPopUp < 1){
    $('#popup').hide();
    
    repeatPopUp++;
    }
    
    }, 15000);
    
    
    });
    </script>
    </body>
    </html>