1
<script> var oTime = setInterval(shijian,1000); function shijian(){ var date = new Date(); document.getElementById("demo").innerHTML = date.toLocaleTimeString(); } function xuan(){ document.getElementById("text").innerHTML; } </script> <body> <button type="button" onclick="setTimeout(myname,3000)">试一试</button> <p id="demo"></p> <button onclick="clearInterval(oTime)">停止时间</button> <button onclick="shijian()">开始</button> </body>
2
<body> <h4>登陆成功</h4> <p> <span id="second">5</span>秒回到主页 <a href="https://www.qzoiedu.com/"> 返回</a> </p> <script> var i = 5; setInterval(count, 1000); function count() { i--; document.getElementById("second").innerHTML = i; if (i == 1) { location.assign("https://www.qzoiedu.com/") } } </script> </body>
3
<body> <h1>第一个页面</h1> <p>欢迎来到第一个页面</p> <button onclick="goToSecondPage()">当前时间</button> <script> function goToSecondPage() { window.location.href = "bigone.html"; } </script> </body> <body> <h1>第二个页面</h1> <p>欢迎来到第二个页面</p> <button onclick="goToFirstPage()">返回第一个页面</button> <script> function goToFirstPage() { window.location.href = "firstPage.html"; } </script> </body>
<body> <p>欢迎</p> <button onclick="goToSecondPage()">前往第二个页面</button> <script> function goToSecondPage() { window.location.href = "secondPage.html"; } </script> <button onclick="goTozhuyem()">返回主页面</button> <script> function goTozhuyem() { window.location.href = "3.html"; } </script> </body>
<body> <p>不欢迎</p> <button onclick="goToFirstPage()">返回第一个页面</button> <script> function goToFirstPage() { window.location.href = "firstPage.html"; } </script> <button onclick="goTozhuyem()">返回主页面</button> <script> function goTozhuyem() { window.location.href = "3.html"; } </script> </body>
4
<style> body{ background-color:aqua; } h2{ text-align: center; } </style> </head> <body> <h2>显示占用区域</h2> <hr> <br> <script type="text/javascript"> function GetWinSize(){ if (navigator.userAgent.indexOf("MSIE") > 0){ var sSize = (document.body.clientWidth * document.body.clientHeight) return sSize; }else{ var sSize=(window.outerWidth * window.outerHeight); return sSize; } } var percent = Math.round(GetWinSize()/(screen.width * screen.height)* 100 ) document.write("此窗口占用当前显示器大约" + percent + "%的区域"); </script> </body>
5
<body> <span id="time"></span> <script> function show() { var date = new Date(); var hour = date.getHours(); var minute = date.getMinutes(); var second = date.getSeconds(); var element = document.getElementById("time"); element.innerHTML = "现在是北京时间"+hour+":"+minute+":"+second; } show(); setInterval("show()",1000); </script> </body>