更新时间:2022-12-11 11:34:18
WebView
提供了 EvaluateJavaScriptAsync
方法(请参见
The WebView
provides an EvaluateJavaScriptAsync
method (see here), that you can use to execute JS.
You could for example subscribe to the Navigated
event (see here)
<WebView VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Source="<SOME_URL_HERE>" Navigated="WebViewOnNavigated" />
,并且当 WebView
导航到后,您可以从后面的代码中执行JS
and when the WebView
has navigated to, you can execute your JS from code behind
public async void WebViewOnNavigated(object sender, WebNavigatedEventArgs args)
{
var webView = sender as WebView; // ommitting the null check, since nobody else will call this method
await webView.EvaluateJavaScriptAsync("<Your JS goes here>");
}