Call back DS HTML page

57 views
Skip to first unread message

Syed Munawer Hassan

unread,
Jan 29, 2023, 9:55:44 PM1/29/23
to DroidScript
When I switch to outside my DS app i.e. brows www.apk4sale.com how can i come back to my local web page ? i.e. i have home.html page in my DS app when I call back home.html it shows error as that html page is not hosted on the server

Jumar

unread,
Jan 30, 2023, 1:49:41 AM1/30/23
to DroidScript
Hi

If you have a native app which has a webview in it where you put the anchor tag. Here a simple app you to try which has a back key to navigate to previous page.

// ------------------ mainApp.js file ------------
function OnStart() {
    // disbable back key default behaviour
    app.EnableBackKey(false);
   
    lay = app.CreateLayout( "linear", "VCenter,FillXY" )    
   
    // your webview
    web = app.AddWebView(lay, 0.9, 0.8);
    web.LoadUrl("myHtml.html");

    app.AddLayout( lay )
}
// handle back key
function OnBack() {
    // check if webview has history
    if( web.CanGoBack() ) web.Back();
}



And you have put your link in your myHtml.html file anchor tag like this



<html>
    <head>
        <script src='file:///android_asset/app.js'></script>
        <title>My Html App</title>
        <script>
            function OnStart() {
                // your code here
            }
        </script>
    </head>
    <body onload="app.Start()">
        <p>Try navigating to this site</p>
        <a href="https://www.apk4sale.com">Go to this site</a>
    </body>
</html>


Regards
Jumar

Dave

unread,
Jan 31, 2023, 2:15:05 PM1/31/23
to DroidScript
You can get back into your app from outside of it when specific urls are navigated to, by using 'deep linking' like this in a build.json file - 

{
    "manifest": {
        "urlScheme": "https",  
        "urlHost": "www.apk4sale.com",
         "urlPathPrefix": "/home"
    }
}

and making a link on your website pointing this path -



But you might want to just keep the user inside your app's webview all the time instead by not using the 'UseBrowser' option.



Reply all
Reply to author
Forward
0 new messages