Reputation: 35
Im currently trying to create a popup that displays when the page loads.
I see the content of the popup, but its just at the top of the page (welcome to my website!) and not actually a new popup window that displays after the page loads. Any ideas why its not working? I tried a variety of suggestions from around stack overflow and website tutorials but nothing seems to work
My html/js stuff:
<html>
<head>
<link rel="stylesheet" type="text/css" href="tooltipster.bundle.min.css"/>
<link rel="stylesheet" type="text/css" href="tooltipster-sideTip-punk.min.css"/>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script type="text/javascript" src="tooltipster.bundle.min.js"></script>
<script>
function PopUp(){
document.getElementById('ac-wrapper').style.display="none";
}
$(document).ready(function() {
$('.tooltip').tooltipster({
theme: 'tooltipster-punk',
'maxWidth': 270, // set max width of tooltip box
contentAsHTML: true, // set title content to html
trigger: 'custom', // add custom trigger
triggerOpen: { // open tooltip when element is clicked, tapped (mobile) or hovered
click: true,
tap: true,
mouseenter: true
},
triggerClose: { // close tooltip when element is clicked again, tapped or when the mouse leaves it
click: true,
scroll: false, // ensuring that scrolling mobile is not tapping!
tap: true,
mouseleave: true
}
});
setTimeout(function(){
PopUp();
},5000); // 5000 to load it after 5 seconds from page load
});
</script>
</head>
<body>
<div id="ac-wrapper">
<div id="popup">
<center>
<h2> welcome to my website! </h2>
</center>
</div>
</div>
(the rest of my html content)
This is my style file:
....
#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;
}
Upvotes: 0
Views: 528
Reputation: 3230
You're close, you flipped the logic by setting the popup to display by default and Popup()
removes it rather than display it.
function PopUp() {
// display content by setting display to "block"
document.getElementById('ac-wrapper').style.display = "block";
}
#ac-wrapper {
display: none; // content not displayed by default
...
}
Upvotes: 1