• js对话框5秒自动消失


    使用了easyui的对话框控件

    <html>
      <head>
        <title>5秒后关闭对话框</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    	<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
    	<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
    	<link rel="stylesheet" type="text/css" href="easyui/demo.css">
    	<script type="text/javascript" src="easyui/jquery.min.js"></script>
    	<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="javascripts/chat.js"></script>
    
        <script type="text/javascript">
    		$(document).ready(function() {
    		 $('#dlg').dialog('close');
    		  var mTime = 5;
    		  var time;
    				
    		  $("#openDlg").click(function(){
    			mTime=5;
    		  document.getElementById("license").innerText=license;
    		  document.getElementById("kind").innerText=kind;
    		  document.getElementById("operator").innerText=operator;
    		  document.getElementById("mTime").innerText=mTime;
    		  $('#dlg').dialog('open');
    		  var interval=setInterval(function(){
    			 var dialog = $("#dlg").parent().is(":hidden");
    			 if (!dialog){
    				 if (mTime>1){
    					mTime=mTime-1;
    					 document.getElementById("mTime").innerText=mTime;
    				 }
    				 else{
    					 $('#dlg').dialog('close');
    					 clearInterval(interval);
    
    				 }
    			 }
    			},1000);
    		  
    		 }
    	});
        </script>
      </head>
      <body>
        <a href="javascript:void(0)" class="easyui-linkbutton" id ="openDlg">打开对话框</a>
        <div id="dlg" class="easyui-dialog" style="400px;height:200px;padding:10px" data-options="buttons: [{text:'确认',iconCls:'icon-ok',handler:function(){alert('ok');}},{text:'取消',handler:function(){alert('cancel');;}}]">
        <label id="mTime"></label>秒后自动确认。
        </div>
      </body>
    </html>
    
  • 相关阅读:
    dos
    jsf session的获取和添加
    tomcat多开造成的端口占用
    myeclipse中tomcat7内存大小的设置
    中文传值乱码过滤
    java定时器
    jsf中jstl标签<c:forEach/>打印信息
    python基础python函数any()与all()的区别
    C# GetManifestResourceStream获取资源为null
    Linux kill 9 和 kill 15 的区别
  • 原文地址:https://www.cnblogs.com/upcyaya/p/5507831.html
Copyright © 2020-2023  润新知