I’m trying to do one app with GWT that will run inside one iframe. Until here everything is ok, the thing is that i have one form in my actual web that will send the request to the iframe. With java script when I push the button “Send Form” I change the src of my iframe and refresh later it:
document.getElementById('iframeSpecialOffers').src = container.url;
document.getElementById('iframeSpecialOffers').contentWindow.location.reload();
The web is running in http://www.example.com:81 and the new src for my iframe in http://www.example.com:8082 and i get this error
Unsafe JavaScript attempt to access frame with URL http://example:8082/Home.html#!TilePage;searchQuery=*;searchMode=1;amount=1;
position='47.3686498,8.539182500000038';leftBottomPosition='47.32023,8.448059899999976';
rightTopPosition='47.43468,8.625370100000055';availabilityEndDate=datetime'2012-08-012T18:00:00';$culture=en
from frame with URL http://example:81/. Domains, protocols and ports must match.
Thanks a lot !
To protect people from XSS attacks (Cross site scripting), browsers do not allow you to access anything inside an iFrame or window that isn’t from the same domain.
However there is some sort of header you can set that tells the browser that cross domain stuff is allowed.
http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
I am not sure that is the route you should go though, it would be much better to avoid that kind of thing.
If your goal is strictly to refresh the page you can do so by just setting the src again, I believe it will refresh by just doing something like:
document.getElementById('iframeSpecialOffers').src = document.getElementById('iframeSpecialOffers').src;But if that doesn’t work you could append a useless queryString parameter to make it different.