gpt4 book ai didi

javascript - 从 Windows 应用程序中的 MainPage.xaml.cs 代码隐藏文件调用 javascript 函数

转载 作者:行者123 更新时间:2023-11-27 23:10:01 26 4
gpt4 key购买 nike

我正在使用 HTML5Javascript (Silverlight) 开发 Windows 8.1 应用程序。我陷入了硬件后退按钮功能的困境。

在 MainPage.xaml.cs 代码隐藏文件中,我想通过以下方法调用 JavaScript 函数:

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
// Here i want to call a javascript function
}

最佳答案

答案如下:

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
Browser.InvokeScript("functionName");
}

参数也可以从这里传递,如下所示:

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
Browser.InvokeScript("functionName","param1");
}

关于javascript - 从 Windows 应用程序中的 MainPage.xaml.cs 代码隐藏文件调用 javascript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36277745/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com