reload parent window from within an iframe

后端 未结 4 675
轮回少年
轮回少年 2020-12-03 11:52

I have my login page in an iframe and wished to reload the parent window using ajax and jquery from within iframe without refreshing but i\'m getting errors like this

(         


        
相关标签:
4条回答
  • 2020-12-03 12:01

    You can use:

    window.parent.location.href = "Create?Param=value";
    

    Or:

    window.parent.location.href = "http://www.stackoverflow.com";
    
    0 讨论(0)
  • 2020-12-03 12:05

    I could achieve this by reloading the page using javascript

    parent.location.reload();
    

    then i fired a trigger to open the target iframe

    $("#log-inout").trigger("click");
    

    I needed such system for a peculiar condition. This might help others in similar conditions.

    0 讨论(0)
  • 2020-12-03 12:10

    dont bother! why use iframes at all if you are using ajax.

    just load the login using

    $("where you want to load the content here").load("src of your iframe here");

    //load via ajax
    $("div").load("login.php");
    

    much simpler and alot more elegant.

    0 讨论(0)
  • 2020-12-03 12:16
    parent.location.href=parent.location.href
    

    gives a smoother result than

    parent.location.reload()
    

    the latter forces a complete reload while the first seems to update more effectively almost like ajax.

    0 讨论(0)
提交回复
热议问题