开发者

reload parent window from within an iframe

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].ow开发者_如何学运维nerDocument || this[0]).createDocumentFragment is not a function
please help!


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.


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.


You can use:

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

Or:

window.parent.location.href = "http://www.stackoverflow.com";


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.


If your iFrame and the main window are exact same domain and port, then you can use

window.top.location.reload()


If trying all of the suggestions made you encounter a violation of "Same Origin Policy" error. You can try this solution instead:

window.parent.location = "URL_OF_PARENT_TO_BE_REFRESHED";

This is quite a brute force approach but if you guys really need a solution, I can offer this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜