Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show popup after page load

I created a jQuery popup by following an online tutorial.

I want to show this popup after page load/after page load it appears + how to code it as like it appears after 5 second of page load.

Due to my low knowledge on jQuery I am not able to make it work as of my requirements.

Any idea how to do it?

function PopUp(){
    document.getElementById('ac-wrapper').style.display="none"; 
}
#ac-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,.6);
    z-index: 1001;
}

#popup {
    width: 555px;
    height: 375px;
    background: #FFFFFF;
    border: 5px solid #000;
    border-radius: 25px;
    -moz-border-radius: 25px;
    -webkit-border-radius: 25px;
    box-shadow: #64686e 0px 0px 3px 3px;
    -moz-box-shadow: #64686e 0px 0px 3px 3px;
    -webkit-box-shadow: #64686e 0px 0px 3px 3px;
    position: relative;
    top: 150px; left: 375px;
}
<div id="ac-wrapper">
    <div id="popup">
        <center>
            <h2>Popup Content Here</h2>
            <input type="submit" name="submit" value="Submit" onClick="PopUp()" />
        </center>
    </div>
</div>

<p>Page Content Here......</p>
like image 401
arifix Avatar asked Dec 02 '22 18:12

arifix


1 Answers

When the DOM is finished loading you can add your code in the $(document).ready() function.

Remove the onclick from here:

<input type="submit" name="submit" value="Submit" onClick="PopUp()" />

Try this:

$(document).ready(function(){
   setTimeout(function(){
      PopUp();
   },5000); // 5000 to load it after 5 seconds from page load
});
like image 135
nrsharma Avatar answered Dec 10 '22 11:12

nrsharma