question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Go back after auto redirect

See original GitHub issue

Bug description: webView.goBack() doesn`t return to previous page if there was auto redirect to the third page.

To Reproduce:

  1. Open link, say site A. (sorry, can not provide real examples, case happens with web resource in the private network)
  2. Click on weblink that redirects to site B that automatically redirects to site C.
  3. Invoke webView.goBack()

Expected behavior: Go back to site A.

Actual behavior: Go to site B and automatically redirect to C - infinite loop.

Environment:

  • OS: Android
  • OS version: Android 9
  • react-native version: 0.59.8
  • react-native-webview version: 5.11.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:6

github_iconTop GitHub Comments

1reaction
philipp65commented, Dec 18, 2019

got stuck for too long with this…it’s not a pure RN WebView issue. Did a workaround which looks simplified like this:

   onNavigationChange = (navState, url) => {
        ...
            if (this.urlparse(url) === this.lastBackUrl) {
                if (this.lastFullBackUrl !== url) {
                    this.backCnt--;
                }
            } else {
                this.backCnt = -1;
            }

            this.lastBackUrl = this.urlparse(url);
            this.lastFullBackUrl = url;
    };

...

    urlparse = (url) => {
        url = url.replace("https://", "");
        url = url.replace("http://", "");
        url = url.replace("www.", "");
        url = url.replace("mobil.", "");
        url = url.split("#")[0];

        return url;
    };

...

goBack = () => {
        this.webview.injectJavaScript(`window.history.go(` + this.backCnt + `);`);
    };
1reaction
Gundam0079commented, Oct 26, 2019

same problem+1
How to fix?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Go back after auto redirect · Issue #733 · react-native-webview ...
goBack () doesn`t return to previous page if there was auto redirect to the third page. To Reproduce: Open link, say site A....
Read more >
Auto redirect users to the previous page - Stack Overflow
I want to automate the process so whenever they visit that page (page123.php) they redirected back to the previous one.
Read more >
How to redirect browser window back using JavaScript
There are two approaches used to redirect the browser window back. Approach 1: Using history. back() Method: The back() method of the window. ......
Read more >
How to use JavaScript to redirect a webpage after 5 seconds?
To redirect a webpage after 5 seconds, use the setInterval() method ... Step 1 − In the first step, we will define a...
Read more >
Redirect Users - Auth0
Redirect Users. You can return users to specific pages (URLs) within your application after validating their ID Tokens (authentication).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found