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