I tried it as well ( elemental2-dom solution) however the behaviour was 
quite different to before so I stopped investigating.
The fix for us was to add a null / blank check to the historyRewrite 
Parameter which resulted in 'URL 'about:blank'' which has a different 
origin than the actual URL and is thus blocked...

Still thank you for your help everyone!

Craig Mitchell schrieb am Mittwoch, 4. Dezember 2024 um 04:52:13 UTC+1:

Apologies, just saw this:  
https://github.com/google/elemental2?tab=readme-ov-file#gwt

Added:  <inherits name="elemental2.dom.Dom"/>

And it's working great!
On Wednesday, 4 December 2024 at 2:45:36 pm UTC+11 Craig Mitchell wrote:

A little off topic, however, I just tried to use elemental2-dom, without 
any success.

I add the lib to my client module:

<dependency>
  <groupId>com.google.elemental2</groupId>
  <artifactId>elemental2-dom</artifactId>
  <version>1.2.3</version>
</dependency>

And then try to use it:

DomGlobal.history.pushState(myUrl, "", myUrl);

And got the error:

[ERROR] Line 190: No source code is available for type 
elemental2.dom.DomGlobal; did you forget to inherit a required module?

So, I added:

<inherits name="elemental2.dom.DomGlobal"/>

to my gwt.xml, and got the error:

[ERROR] Unable to find 'elemental2/dom/DomGlobal.gwt.xml' on your 
classpath; could be a typo, or maybe you forgot to include a classpath 
entry for source?

Any idea what I'm doing wrong?

Thanks.

On Wednesday, 4 December 2024 at 5:05:41 am UTC+11 Colin Alworth wrote:

First... you should update this to use jsinterop - consider just adding 
elemental2-dom to your project and calling DomGlobal.history.pushState(new 
Object(), "", historyRewrite); in plain Java?

To answer the question more directly, you probably need to change "window" 
to "$wnd" to access the actual outer window. Your current code, as written, 
is technically attempting to change the URL of the iframe that the app is 
loaded in.
On Tuesday, December 3, 2024 at 11:43:00 AM UTC-6 Lonzak wrote:

I successfully updated GWT from 2.10.1 to 2.12.1.
In Firefox everything works perfectly however not in chrome based browsers. 
When I try to
execute the following code:

public static native int setHistory(String historyRewrite) /*-{

window.history.pushState({}, '', historyRewrite);

}-*/;

*Error:*
SEVERE: (SecurityError) : Failed to execute 'pushState' on 'History': A 
history state object with URL 'https://company.url/home' cannot be created 
in a document 
with origin 'https://company.url' and URL 'about:blank'.
com.google.gwt.core.client.JavaScriptException: (SecurityError) : Failed to 
execute 'pushState' on 'History': A history state object with URL 
'https://company.url/home' cannot be created in a document with origin '
https://company.url' and URL 'about:blank'.

If I revert to GWT it works again.
Any idea what changed (and how to fix it)? 
Is the script maybe loaded before the document is fully loaded?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/google-web-toolkit/d6528117-7a6b-4d95-ab2f-5f3d1e2c640cn%40googlegroups.com.

Reply via email to