Redirect to an internal html page, staying in the webview

Hi.

When my app is launched (from index.html), for some reason, i need to go to another page (let say about.html).

In JS, i try a window.open(‘about.html’, ‘_self’), but it keep open the external browser on the device…

How to do this, staying in the app webview ? I tried to go to the result of tool.getURL, but it keep opening external browser with window.open

Thanks

PS : problem is on Android (9 or 10).
On ios, window.open(‘about.html’) work perfectly

I tested window.open(‘about.html’,’_self’) on

  • FORGE / ios : it stay on the WKWebView, OK
  • Cordova / ios & android : it’s OK
  • Capacitor ios & android : OK
  • FORGE Android : it open external browser…

So it’s not a problem related to webview system. It’s forge internal problem i suppose

What are you actually trying to do in your app? Window.open may not be what you should be using…

If what you are trying to do is navigate to another page in your app then using a simple href should work because the application is running as httpd or localhost so its not different in that case.

If you must use JS to navigate in terms of an onclick event then window.location should be used as window.open for a new tab not to redirect.

Further to that point, using ui frameworks can really go a long way to help, with built in routing etc it can make building the application much easier.

Hello and thank you.

Yes, my question could make you think it was a beginner question, i should have explained more :

It’s more for development phase use. I use 3 differents framework (quasar, Framework7, etc…) and i have 4 apps to test and make test to others. I want to embed all those apps in one development app. So At launche, my index.html make a “redirect” to 1 of the 4 folders containing my apps (and share js libs at root level for information).

I was thinking it was very easy (and it work on most cases) except Forge + Android.

As i always want to understand, i keep trying make it work, and i would like to understand why Forge keep opening external browser

Regards

It looks like the built-in webserver doesn’t automatically get added to the trusted_urls list on Android.

Try adding the following to the "general" section of your src/config.json:

"core": {
    "general": {
        "trusted_urls": [
            "http://localhost/*",
            "https://localhost/*"
        ],
        ... rest of config ...

Thank you muchly for reporting this, I’ll fix it in the v2.9 release.

Perfect ! It works with trusted_url configuration.

Thanks for this.

1 Like