0
我有以下代碼如何在關閉fancybox時停止頁面重定向?
<script type="text/javascript">
jQuery(document).ready(function() {
beginCartnotification();
});
setTimeout(function() {
window.location.href = "http://www.someurl.com";
}, 5000);
</script>
<script type="text/javascript">
jQuery.fancybox({
'width': '300',
'height': '90',
'padding': '40px',
'autoDimensions': false,
'border': '1px solid #005195',
'autoScale': false,
'transitionIn': 'fade',
'transitionOut': 'fade',
'showCloseButton': true,
'type': 'inline',
'href': '#cartnotification-popup',
'onClosed': function(){ //perform some task on closing the fancybox.}
});
}
</script>
現在我想要做的是,如果對看中框中關閉按鈕用戶點擊,頁面不應該重定向。
如果用戶在5秒後沒有點擊關閉按鈕,用戶應該被重定向到另一個頁面。
我該怎麼實現裏面關閉函數?
加一,不過,我想保持'。就緒()'方法中的fancybox初始化腳本。另外請注意,您的代碼末尾可能會出現雜亂的右括號'}' – JFK
@JFK絕對正確。 Thx編輯了這篇文章。 – DavidDomain