為什么我跳轉總是跳到慕課網錯誤頁面?
<!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>
五秒后跳轉如下圖:
2015-12-27
window.open('http://'+location.hostname);