Closed vasanthnataraj closed 2 weeks ago
The JS code of your GWT app lives in an iframe that the app creates for you. This is controlled by GWT's linker and by default the xsiframe
linker is used.
So it is like:
iframe (2) stores the GWT URL parameters and place tokens. iframe (3) does not have any href at all.
So now it is important that you tell us what exactly is window.Location.getHref()
? Is it GWT SDK Java code? Is it JS code via JSNI? Is it elemental2 library code? How do you obtain the window
variable?
If it is JS code via JSNI in your GWT app then window
points to iframe (3) and it is expected that you receive the base URL. The reason is that iframe (3) does not have any href and the browser returns the base URL of iframe (2). In that case you would need to use $wnd
instead of window
, because it will point to the window object of iframe (2) as you would expect.
The Window.Location.getHref()) is a GWT SDK Javacode [com.google.gwt.user.client] . Window.Location.getHref()) returns the parameters and place tokens correctly at all times, but if the GWT APP receives an window.postmessage event from the parent page then Window.Location.getHref()) returns the base url + the eventmessage
we have a simple html page which has a iframe in it. Inside the iframe we have our GWT application loaded.
(1 - Parent) The simple html page fires window.postmessage(HelloMessage) via javascript to the GWT APP (2 - Child) GWT app -> receives event hellomessage. Now Window.Location.getHref() returns only the base url+eventmessage
Window.Location.getHref() returns http://127.0.0.1//mygwtapp.html?loginPlace=true&userId=8&loginId=9. ---(Correct)
Window.Location.getHref() returns http://127.0.0.1//mygwtapp.htmlHelloMessage ---(Wrong)
GWT's Window.Location.getHref()
simply calls JS $wnd.location.href
with $wnd
pointing to your GWT app iframe window. Also GWT SDK does not have any postMessage
code or message
event handler code. So GWT itself will not change the href
.
If something changes the href
then the browser usually loads the new href
. In your example I would expect a HTTP 404 NOT FOUND for the new iframe href
because mygwtapp.htmlHelloMessage
surely doesn't exist. So it is pretty weird if you receive a different href
as you said.
I assume it is something in your app or a browser bug. Can you reproduce it in a small app?
Note that it is also possible to change the window.location and href without reloading the page via pushState and friends.
Agreed that with the information provided this doesn't make sense without an application bug, a reproducer would help.
Any more detail on this, or can we close it as being specific to the application?
GWT version:2.11.0 Browser (with version):chrome **Operating System:chrome 130
Description
Steps to reproduce
When there is a event received from the parent frame (window.postmessage()) to a child frame , In this case the GWT app is loaded in the chhild frame. The window.Location.getHref() returns only the base URL , all other parameters and place tokens are removed from the GWT URL.
Known workarounds
Links to further discussions