Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
141
rated 0 times [  146] [ 5]  / answers: 1 / hits: 50464  / 13 Years ago, mon, may 23, 2011, 12:00:00

Good day to all.



I have a page that includes an iframe. In that iframe I have a script with function called test(). I need to access the function from the parent window. After asking around I got to this solution:



<div onclick=document.getElementById('targetFrame').contentWindow.teste();>Test</div>


On click the test function should be run. The problem is that I get Permission denied to access property test error.



It looked like a permission error to me so I changed the file loaded in iframe permissions to 777, but without any result.



Note: The file loaded in iframe is not on the same domain.


More From » iframe

 Answers
16

It's prohibited to access pages from other domains by default, because browsers use same origin policy. There are several workaround like using location.hash or window.name to communicate between frames. The most recent and standardized in HTML5 is postMessage-interface.
There is library for cross-browser solution http://easyxdm.net/wp/.


[#92104] Saturday, May 21, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
arron

Total Points: 663
Total Questions: 119
Total Answers: 112

Location: Belize
Member since Mon, Jun 20, 2022
2 Years ago
;