為什么我跳轉(zhuǎn)總是跳到慕課網(wǎng)錯(cuò)誤頁(yè)面?
<!DOCTYPE?html> <html> ?<head> ??<title>瀏覽器對(duì)象</title>?? ??<meta?http-equiv="Content-Type"?content="text/html;?charset=gkb"/> ??<style?type="text/css"> #opt{ ???font-weight:bold;/*設(shè)置字體加粗*/ } </style> ?</head> ?<body> ??<!--先編寫好網(wǎng)頁(yè)布局--> ??<p?id?=?"opt"> ??????操作成功 ??</p> ??<p> ??????5秒后回到主頁(yè)?<a?href=""?onClick="goBack()">?返回</a> ??</p> ? ??<script?type="text/javascript">?? ? ???//獲取顯示秒數(shù)的元素,通過(guò)定時(shí)器來(lái)更改秒數(shù)。 ???var?i?=?setTimeout("goHome()",5000); ???//通過(guò)window的location和history對(duì)象來(lái)控制網(wǎng)頁(yè)的跳轉(zhuǎn)。 ???function?goBack()?{ ???????history.back(-1); ???} ???function?goHome()?{ ???????window.open(location.hostname); ???} ???//document.write(location.hostname); ?</script>? </body> </html>
五秒后跳轉(zhuǎn)如下圖:
2015-12-27
window.open('http://'+location.hostname);