【问题标题】:c# call javascript function written in hosting application from webview control in client applicationc#从客户端应用程序中的webview控件调用在托管应用程序中编写的javascript函数
【发布时间】:2017-01-13 11:41:04
【问题描述】:

我有一个使用 Webview 控件的 UWP 应用。 webview 的来源是在 localhost 上运行的 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 函数?

【问题讨论】:

    标签: javascript c# webview asp.net-mvc-5 uwp


    【解决方案1】:

    如果我正确理解了您的问题。您想在源 URL 中调用 Javascript。在这种情况下,您可以使用InvokeScript 方法。

    您可以在 StackOverflow How to invoke javascript functions in a WebView in Universal Windows App 上参考此问题以获取更多详细信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多