开发者

locally held iframe parent location issue

开发者 https://www.devze.com 2023-03-27 14:21 出处:网络
So I am holding a html file on my desktop that has an iframe within it. This iframe is all good but I want a button within it to control the location of the web page hosting it.

So I am holding a html file on my desktop that has an iframe within it.

This iframe is all good but I want a button within it to control the location of the web page hosting it.

So I want the iframe's parent to go back in history by 1开发者_C百科 page, I used this method but it did not work. How would you do this?

onClick="parent.history.go(-1)"


If the inner iframe is on a different host that the outer frame (or even two different URL protocols like file: and http:), you will have trouble making a direct call, because the browser is preventing cross-site scripting vulnerabilities.

One thing that works is in that case is cross-window messaging using postMessage(). Check out http://ejohn.org/blog/cross-window-messaging/ for an example.

0

精彩评论

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