Skip to content

Commit

Permalink
Fixed possible unwanted side effect on parent window history in HtmlW…
Browse files Browse the repository at this point in the history
…ebViewPeer
  • Loading branch information
salmonb committed Nov 18, 2023
1 parent 92baeee commit 109477f
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,16 @@ public void updateUrl(String url) {
// In general, we use iFrame.src, but it doesn't report any network errors despite iFrame.onerror, which can
// be annoying in some cases. So we propose a prefetch alternative mode.
boolean usePrefetch = Booleans.isTrue(getNode().getProperties().get("webfx-prefetch"));
if (!usePrefetch)
iFrame.src = url;
else {
if (!usePrefetch) {
// Commented the following code (iFrame.src = url) because it has a side effect on the parent window
// navigation when the url changes several times. The first time has no side effect, but the subsequent
// times add an unwanted new entry in the parent window history, so the user needs to click twice to go
// back to the previous page, instead of a single click.
//iFrame.src = url;

// Using the iframe location replace() method seems to work better without that side effect explained above.
iFrame.contentWindow.location.replace(url);
} else {
// For a better error reporting, we prefetch the url, and then inject the result into the iFrame, but
// this second method is not perfect either, as it may face security issue like CORS.
iFrame.contentWindow.fetch(url)
Expand Down

0 comments on commit 109477f

Please sign in to comment.