![](/img/trans.png)
[英]How do I get my bouncing hamburger menu to stop bouncing after a certain amount of seconds have passed once the page loads?
[英]How do I get Colorbox to display 5 seconds after the page loads?
這是我到目前為止,但它立即加載:
<script type="text/javascript">
var pid = <?php echo $_GET['id']; ?>;
var rlink = "<?php echo $domain; ?>share.php?pid=" + pid;
$(document).ready(function(){
setTimeout($(".url_tag_small").colorbox({ href: rlink, width: "620px", height: "354px", opacity: 0.0, transition: "none", initialWidth: "620px", initialHeight: "354px", iframe: true, title: true, open: true}), 5000);
});
</script>
我究竟做錯了什么?
它在初始化setTimeout
調用時執行回調,而不是在定時器關閉時執行。 把它改成這個:
var pid = <?php echo $_GET['id']; ?>,
rlink = "<?php echo $domain; ?>share.php?pid=" + pid;
$(document).ready(function(){
setTimeout(function(){
$(".url_tag_small").colorbox({
href: rlink,
width: "620px",
height: "354px",
opacity: 0.0,
transition: "none",
initialWidth: "620px",
initialHeight: "354px",
iframe: true,
title: true,
open: true
})
}, 5000);
});
您在調用setTimeout
調用該函數,而不是將其引用到將打開顏色框的函數。
$(document).ready(function(){
setTimeout(function() {
$(".url_tag_small").colorbox({ href: rlink, width: "620px", height: "354px", opacity: 0.0, transition: "none", initialWidth: "620px", initialHeight: "354px", iframe: true, title: true, open: true})
}, 5000);
});
基本上,你的版本,而不是傳遞一個函數來說,“這是我希望你在5000毫秒后做的事情”,編碼調用.colorbox 之前調用setTimeout
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.