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:
Code:
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:
Code:
Note: I am using jQuery.
The above will give you an error in Google Chrome when you will open the file directly from windows explorer. The error will look like this:
Unsafe JavaScript attempt to access frame with URL file:///C:/Users/extremedevShowModalDialogSample/extremedevStart.html from frame with URL file:///C:/Users/extremedevShowModalDialogSample/extremedevTestPopup.html. Domains, protocols and ports must match.
For some reason Google Chrome considers page2.html a different domain and does not allow to access the content of the frame.
However this error will not appear if you will open those pages through Visual Studio, by doing the following steps:
- Open Visual Studio;
- Go to File -> Open -> Web Site;
- Select the folder where your html files are located;
- Press Open;
- Select the starting file;
- Right Click on it and press: View in Browser;
- Now your pages will work correctly without any errors.
I hope this article helped you and ... thanks for visiting my blog.
Please share this article with others!
10 comments:
Chrome treats every file:// URL as its own domain, so each is isolated from all the others. It does this as a security mechanism to prevent one rogue file from being able to access your whole system. Or something.
Yes, that's correct.
Thanks for visiting my blog,
Roman
man, your site is called extremedev and you use windows T.T
yes, it's extreeeme :)
Anonymous 12 December, 2011 23:39,
I am not sure I understand you.
Regards,
Roman
They were trying to imply that the most important criterion for determining the skill of a developer is the operating system that one uses.
lol. extremedev and you don't even know how webkit works? you're funny :)
I got the below exception in Safari:
Unsafe JavaScript attempt to access frame with URL https://newclassroom2.qaols.phoenix.edu/Tutor/TutoredFormativeAssessment.jsp?firstname=JOHN&lastname=ELLIOTT from frame with URL https://newclassroom2.qaols.phoenix.edu/Tutor/tutoredformativeassessment/AD3916F5E8AC7BE7E0E6C4E6616F1FB3.cache.html. Domains, protocols and ports must match.
here i am using the same port and domain .can anyone give solution for this.
Anonymous, one singple person can not know everything.
Thanigai arasu, sorry, I don't know why this is happening.
@Roman: You're wrong. I happen to know EVERYTHING...
Post a Comment
your thoughts are welcome: