慕标1082868
2015-12-27 16:50
<!DOCTYPE html> <html> <head> <title>浏览器对象</title> <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> <style type="text/css"> #opt{ font-weight:bold;/*设置字体加粗*/ } </style> </head> <body> <!--先编写好网页布局--> <p id = "opt"> 操作成功 </p> <p> 5秒后回到主页 <a href="" onClick="goBack()"> 返回</a> </p> <script type="text/javascript"> //获取显示秒数的元素,通过定时器来更改秒数。 var i = setTimeout("goHome()",5000); //通过window的location和history对象来控制网页的跳转。 function goBack() { history.back(-1); } function goHome() { window.open(location.hostname); } //document.write(location.hostname); </script> </body> </html>
五秒后跳转如下图:
window.open('http://'+location.hostname);
JavaScript进阶篇
468788 学习 · 22582 问题
相似问题
回答 1
回答 2