我有一个使用 Webview 控件的 UWP 应用。 Webview 的源是本地主机上运行的 ASP.NET Web 应用程序的 URL。 url 中写入了 javascript 函数。我的问题是如何从 uwp webview 控件调用在 Web 应用程序中编写的 javascript 函数。
<Page
x:Class="signalRonRPi3.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:signalRonRPi3"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel>
<Button x:Name="callJS" HorizontalAlignment="Stretch" Margin="0,0,298,0" Click="callJS_Click" >Call JS</Button>
<WebView x:Name="webViewUrl" Source="http://localhost:52527/Home/Image" Height="500" Width="500" Margin="50" />
</StackPanel>
如何从这里调用源 url 中编写的 JavaScript 函数?
最佳答案
如果我正确理解你的问题。您想要在源 url 中调用 Javascript。在这种情况下,您可以使用 InvokeScript方法。
您可以在 StackOverflow How to invoke javascript functions in a WebView in Universal Windows App 上引用这个问题以获得更多详细信息。
关于javascript - C#从客户端应用程序中的WebView控件调用托管应用程序中编写的JavaScript函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39341815/