My GWT app is being added to an iframe. I have a button in the app which then should direct to another page. Currently, I’m doing it like this:
Window.Location.assign("http://testpage.com");
The problem right now is that new page is being loaded into the iframe. Is there a way to reload the whole page to avoid having that effect?
I have read some posts here on stackoverflow but none of them where in GWT. I hope someone already had the problem and solved it successfully.
Thanks for any advices!
I don’t believe GWT has a built in function you can call for this.
The usual idiom in JavaScript to do this looks like this
This won’t work directly in GWT, though you could put it in your main html page, probably in the
<head>before the rest of the app loads – this will kick you out of the iframe right away instead of waiting for the app to load, breaking out, then waiting for the app to load again.If you really want to run the check in GWT, perhaps because you only sometimes want to break out, you’ll need a very short JSNI method to add this feature, something like this:
Note the use of $wnd to refer to the app’s window object. See http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html for more details on writing JSNI. Do not expect this function to return – it is triggering the browser to unload this page and load another.