How to reload Main Page from within an iFrame

后端 未结 7 6324
死守一世寂寞
死守一世寂寞 2020-12-04 13:54

Within my scenario, I have a button within an iframe section of my page that performs some database processing.

What I need is a means of performing a page refresh o

相关标签:
7条回答
  • 2020-12-04 14:34

    If the parent's and child iframe domains will be different you will get cross-window security error, in that case you can try to use following:

    window.parent.location = document.referrer;
    
    0 讨论(0)
  • 2020-12-04 14:35

    If you code Page with aspx C# you can view code:

    ClientScript.RegisterStartupScript(this.GetType(), "LoadParent", "<script language=javascript>window.parent.location.reload();</script>");
    
    0 讨论(0)
  • 2020-12-04 14:39

    define allFrame variable on your top frame:

    var allFrame=1
    

    and on all your frames check this function

    if(top.allFrame === undefined)
    {
        window.parent.location = "your website top frame";
    }
    
    0 讨论(0)
  • 2020-12-04 14:42
    window.opener.top.location.reload();
    
    0 讨论(0)
  • 2020-12-04 14:46

    We can easily achieve the facing goal by set target="_parent" to the Links which inside the iframe.

    Just like the following demo shows:

    <!--ParentPage.htm-->
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
    </head>
    <body>
    Parent Page
    <iframe src="FramePage.htm"></iframe>
    </body>
    </html>
    
    
    <!--FramePage.htm-->
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    </head>
    <body>
    <a href="http://www.g.cn" target="_parent">hello</a>
    </body>
    </html>
    
    0 讨论(0)
  • 2020-12-04 14:51
    window.parent.location.reload();
    
    0 讨论(0)
提交回复
热议问题