js点击隐藏和显示div

来源:互联网 发布:php 图片上传的原理 编辑:程序博客网 时间:2024/05/18 13:30
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>display</title>    <script type="text/javascript">         function hidetext()  {  var mychar = document.getElementById("con").style.display ="none";        }  function showtext()  {  var mychar = document.getElementById("con").style.display ="block";        }    </script> </head> <body>      <h1>JavaScript</h1>      <p id="con">做为一个Web开发师来说,如果你想提供漂亮的网页、令用户满意的上网体验,JavaScript是必不可少的工具。</p>     <form>       <input type="button" onclick="hidetext()" value="隐藏内容" />        <input type="button" onclick="showtext()" value="显示内容" />     </form></body> </html>

商务通弹窗修改,打开网页5秒后弹窗,点击关闭,5秒后再次弹窗

function showtext()  {  var mychar = document.getElementById("bar1").style.display ="block";                      }setTimeout("showtext()",6000);//6秒   function hidetext()  {  var mychar = document.getElementById("bar1").style.display ="none";                setTimeout("showtext()",6000);//6秒  }  document.writeln("<style type=\'text/css\'>");document.writeln(".dialog{");document.writeln(" position: fixed;");document.writeln(" _position:absolute;");document.writeln(" z-index:999999;");document.writeln(" top: 50%;");document.writeln(" left: 50%;");document.writeln(" display: none;");document.writeln(" margin: -135px 0 0 -140px;");document.writeln(" width: 280px;");document.writeln(" height:270px;");document.writeln(" background:#339933;");document.writeln("} ");document.writeln(".guanbi{ top:0px; height:25px; width:30px; right:0px; position:absolute; cursor:pointer}");document.writeln("</style>");document.writeln("<div class=\'dialog\' id=\'bar1\'><span class=\'guanbi\' onclick=\'hidetext()\'></span><a href=\'/swt/\'><img src=\'/swt/1.gif\'/></a></div>");


0 0