javascript - iframe - location - same origin policy -


as believing, iframe properties (if iframe loaded origin) can not set. tried little testcases, seems can properties. doing wrong in setting example?

<iframe src="http://www.wikipedia.org" id="iframe"></iframe>  <script>      try {         alert(document.getelementbyid("iframe").src);     } catch(e) {         alert(e);     }  </script> 

the above example alerts correct location in tests.

regards

you not accessing content elements/properties of contained document. getting src attribute of iframe set outer document. try this:

iframeelement.contentdocument.body.style.backgroundcolor = "red"; 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -