Access javascript file locally in Xamarin Forms

Asked

Viewed 47 times

0

I have a question about how to access a file . js in my application mobile(Andriod)using Xamarin Forms,as below :

var htmlSource = new HtmlWebViewSource();

htmlSource.Html =
           @"<html>
                <head>
                    <script type='text/javascript'>

                     function LaunchSCO(organizationItemID,href) {
                        alert(""Ola"");
                        windows.API = new teste();
                    }
                    </script>
                  </head>
                  <body>
                        <a href=""javascript:LaunchSCO('4020','');"" style='text-decoration:none;'>Abrir cursoooooS</a>
                        <div id='divCurso'>

                        </div>
                  <--Aqui é o arquivo que eu quero abrir localmente-->
                  <script src=""js/teste.js""></script>
                  </body>
            </html>";

WebView1.Source = htmlSource;

My difficulty is where I should store this file and how do I access it when I generate my APK.

Note:I looked for File in Xamarin but I did not find a practical way to guard and read js file.

  • Xamarin does not perform javascript. The component WebView is what it does. you need to have a page already defined in the webview that contains this javascript and emulate from it.

  • Or else run with Eval. WebView1.Eval(/* Chamar função javascript da página*/);

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.