被iframe页面更改顶层的跳转链接

界面被其他网页Iframe,需要修改顶层链接---方法如下

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <iframe src="./b.html" frameborder="0"></iframe>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button onclick="myButton()">跳轉頂級頁面</button>
  <script>
    function myButton() {
      console.log('aaa')
      window.top.location.href = 'http://10.10.10.11:6868/login.html'
    }
  </script>
</body>
</html>

 

posted @ 2020-06-28 20:57  糖~豆豆  阅读(646)  评论(0编辑  收藏  举报
Live2D