为什么我跳转总是跳到慕课网错误页面?
<!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>五秒后跳转如下图:
