16 May 2011

Unsafe JavaScript attempt to access frame with URL in Chrome

Hello everybody,

This time I have found an interesting issue with Google Chrome browser.
The problem appears when you try to access the code from within the iframe which source has an url from the same domain.
For example you have two simple html files on your computer (ie page1.html and page2.html), where one of them contains an iframe:

<iframe src='page2.html' id='myFrame' />

If you try to change  or get something in/from page2.html through javascript you will have an error in Google Chrome. I will give an example with getting the title through javascript from inside page1.html like this:

Need more? Leave comments and subscribe to my blog.