我试图在每10分钟的时间间隔打开弹出窗口并在15秒内自动关闭.
以下代码用于弹出窗口,打开进入点击事件但我想自动打开10分钟的时间间隔.
<script type="text/javascript">
$("[id*=btnPopup]").live("click", function () {
$("#dialog").dialog({
title: "jQuery Dialog Popup",
buttons: {
Close: function () {
$(this).dialog('close');
}
}
});
return false;
});
</script>
<div id="dialog" style="display: none">
This is a simple popup
</div>
Run Code Online (Sandbox Code Playgroud)
请帮忙 :(
你需要使用setInterval和的组合setTimeout.
您还需要在按钮的单击处理程序之外初始化对话框.
码
$(document).ready(function() {
//Initialize dialog
$("#dialog").dialog({
title: "jQuery Dialog Popup",
autoOpen: false,
buttons: {
Close: function() {
$(this).dialog('close');
}
}
});
//bind click handler
$("[id*=btnPopup]").live("click", function() {
$('#dialog').dialog('open');
return false;
});
//Open dialog
setInterval(function() {
$('#dialog').dialog('open');
//Close after 15 seconds
setTimeout(function() {
$('#dialog').dialog('close');
}, 15000);
}, 600000);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3826 次 |
| 最近记录: |