Reputation: 1032
I use following code to load page to MyWebView
:
private void DisplayLocalPage(string filename)
{
var html = new HtmlWebViewSource();
html.BaseUrl = DependencyService.Get<IBaseUrl>().Get();
html.Html = ReadFile(filename);
MyWebView.Source = html;
MyWebView.Eval("alert(200)");
}
Page is rendered well - all scripts run too, but this alert isn't fired, what are possible reasons?
Upvotes: 2
Views: 3755
Reputation: 81
Please try this:
webView.Navigated += (o, s) => {
webView.Eval("alert('text')");
};
Upvotes: 3
Reputation: 1032
I think I figured out why it might not work. The Eval is triggered before the WebView is fully initialized or web page is rendered, so the script is trigerred, but doesn't have any effect.
Upvotes: 0