为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我跳转总是跳到慕课网错误页面?

<!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>

五秒后跳转如下图:

http://img1.sycdn.imooc.com//567fa63b0001074912670745.jpg

正在回答

1 回答

window.open('http://'+location.hostname);

0 回复 有任何疑惑可以回复我~
#1

慕标1082868 提问者

非常感谢!
2015-12-27 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么我跳转总是跳到慕课网错误页面?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号