JS页面跳转(链接,超链接)

<!DOCTYPE html>
<html>
<head>
    <title>链接和超链接</title>
</head>
<body>
    <a href="http://www.baidu.com">链接--当前页面打开--相当于window.location.href</a>
    <br>
    <a href="http://www.baidu.com" target="_blank">超链接--新窗口打开---相当于window.open</a>
    <br>
    <button id="btn">按钮</button>
 <script type="text/javascript">
     var btn = post.getElementById('btn') 
     btn.onclick = function () {
         console.log(111)
         // window.location.href = 'http://www.baidu.com'  //当前页面打开
         window.open('http://www.baidu.com')  //新窗口打开
     }
  </script>
</body>
</html>

 

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享