vue:

<!--内嵌页面-->
<div class="read_heton" v-if="packOff">
    <iframe src="https://www.baidu.com"
            frameborder="0"
            width="100%"
            height="100%">
    </iframe>
</div>

直接设置:
this.packOff = false;
if(res.success){
          parent.location.reload(); //刷新整个当前页
}

window.location.href  location.href 本页面跳转
parent.location.href  上一层页面跳转
top.location.href 最外层页面跳转

 

function loadUrl(url) {
        if (window != top){
            top.location.href = url;
            return;
        }
        window.location.href = url;
    }

设置父页面url跳转

top.location = 'path'
or 
top.location.href = 'path'

iframe里面 按钮点击 关闭当前iframe

//父页面有iframe的
<body>
    <iframe id="main" src="test.htm"  frameborder="no" ></iframe>
</body>

iframe页面:
<div class="wrap" id="btn"> 
        点击隐藏
</div> 
<script type="text/javascript">
  document.getElementById("btn").onclick = function(){
    window.parent.document.getElementById("main").style.display="none";
  }
 </script>

 

Logo

前往低代码交流专区

更多推荐