美文网首页
iframe页面跳转刷新父页面窗口问题

iframe页面跳转刷新父页面窗口问题

作者: 迦叶凡 | 来源:发表于2019-02-01 10:26 被阅读0次

    前言

    实际工作中遇到了iframe里嵌套的页面的跳转问题,上网查了一下,现在查到的做一下记录。

    正文

    先假设A,B,C,D都是页面,D是C的iframe,C是B的iframe,B是A的iframe,在D中跳转页面的写法区别如下:
    js跳转:

    • window.location.href、location.href:本页面跳转,即D页面跳转
    • parent.location.href:上一层页面跳转,及C页面跳转
    • top.location.href: 最外层的页面跳转,即A页面跳转
      页面刷新:
    • parent.location.reload(): C页面刷新
    • parent.main.location.reload(): parent是代表父级页面,main可能是父级页面里的一个iframe,整个意思就是让name=”main”的iframe页面刷新
    • window.opener.document.location.reload():C页面刷新(使用子窗口的opener对象来获得父窗口对对象)
    • top.location.reload():A页面刷新

    form或者链接:
    D页面中有form

    • <form>: form提交后D页面跳转
    • <form target=”_blank”>: form提交后弹出新页面
    • <form target=”_parent”>:form提交后C页面跳转
    • <form target=”_top”>:form提交后A页面跳转

    相关文章

      网友评论

          本文标题:iframe页面跳转刷新父页面窗口问题

          本文链接:https://www.haomeiwen.com/subject/biwrsqtx.html