[英]Javascript Pop up not popping up?
我目前正在嘗試創建一個在頁面加載時顯示的彈出窗口。
我看到了彈出窗口的內容,但它只是在頁面頂部(歡迎訪問我的網站。),而不是在頁面加載后顯示的新彈出窗口 window 嗎? 任何想法為什么它不起作用? 我嘗試了有關堆棧溢出和網站教程的各種建議,但似乎沒有任何效果
我的 html/js 東西:
<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)
這是我的樣式文件:
....
#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;
}
您很接近,您通過將彈出窗口設置為默認顯示來翻轉邏輯,並且Popup()
將其刪除而不是顯示它。
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
...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.