Is it allowed to import the «android_asset/app.js» from «webview.LoadUrl(page)»?

188 views
Skip to first unread message

Carl Carlson C18

unread,
Dec 18, 2023, 10:08:33 AM12/18/23
to DroidScript
As I saw in this script, it is allowed to execute DroidScript-JavaScript from a Navigator-JavaScript event. But the examples I have seen so far, are only with the method «webview.LoadHtml». This strategy of loading HTML in the WebView does not allow me to reuse code applications as it is, to import css, js and other files from local, and it makes me change a lot of things in my way of developing apps.

My question is if there was any way of importing the «android_asset/app.js» file, which makes it possible to call DroidScript-JavaScript functions from Navigator-JavaScript events.

Thank you.

Chisan Gelu

unread,
Dec 18, 2023, 6:14:41 PM12/18/23
to DroidScript
Alternative is to choose the type of your application to be HTML .This is when you create your app.
In HTML app you can use app object....  


<html>
<head>
    <meta name="viewport" content="width=device-width">
    <script src="ds:/Sys/app.js"></script>
</head>

<script>
    //Called after application is started.
    function OnStart()
    {
        app.ShowPopup( "HTML Rocks!" );
    }
</script>

<style>
body { background-color: #ffffff; }
    .hello
    {
        font-size: 42;
        width: 100%;
        margin-top: 2em;
        text-align: center;
        color: blue;
    }
</style>

<body onload="app.Start()">

<div class=hello> Hello World! </div>

</body>
</html>

Chisan Gelu

unread,
Dec 18, 2023, 6:18:33 PM12/18/23
to DroidScript
And using cfg.Serv files will be served from a local server . in HTML app .

Chisan Gelu

unread,
Dec 18, 2023, 6:20:40 PM12/18/23
to DroidScript
Check this thread from premium for cfg.Serv  

Alan Hendry

unread,
Dec 21, 2023, 7:52:39 AM12/21/23
to DroidScript
HI,
Not sure I understand the question
In a Native DS project you can use CreateWebView,
which has methods Execute and Func
Within the Webview itself you can console.log to invoke a callback (SetOnConsole)
Regards, ah
Reply all
Reply to author
Forward
0 new messages