reload parent window from within an iframe

2020-01-29 07:50发布

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

(this[0].ownerDocument || this[0]).createDocumentFragment is not a function
please help!

4条回答
何必那么认真
2楼-- · 2020-01-29 08:18

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.

查看更多
祖国的老花朵
3楼-- · 2020-01-29 08:32

You can use:

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

Or:

window.parent.location.href = "http://www.stackoverflow.com";
查看更多
beautiful°
4楼-- · 2020-01-29 08:34
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.

查看更多
放荡不羁爱自由
5楼-- · 2020-01-29 08:41

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.

查看更多
登录 后发表回答