locally held iframe parent location issue
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.
精彩评论