gpt4 book ai didi

c# - 在 Internet Explorer 10 中从 Javascript 调用 C# BHO 方法(发布预览)

转载 作者:太空狗 更新时间:2023-10-29 20:42:07 29 4
gpt4 key购买 nike

我正在尝试为 IE 10 的发布预览开发 BHO。BHO 需要能够允许 javascript 调用 C# 函数。

我已按照此处提供的说明进行操作:

Calling C# BHO methods from Javascript

这些说明在 IE 9 中运行良好。

不幸的是,我发现它们只适用于在 IE 10 中创建的第一个选项卡。第二个和后续选项卡不会向 Javascript 公开 BHO 接口(interface)。有时,新选项卡会起作用,但大多数时候它们不起作用。而且,它默默地失败了。我猜这与进程模型有关——但同样,它在 IE 9(具有相同的进程模型)中运行良好。

这是我正在使用的特定代码片段:

private void InstallJSObject(IHTMLWindow2 window)
{
// Install our javascript object
IExpando windowEx = (IExpando)window;

PropertyInfo property = windowEx.GetProperty("myBHO", System.Reflection.BindingFlags.IgnoreCase);
if (property == null)
{
property = windowEx.AddProperty("myBHO");
}
property.SetValue(windowEx, this, null);
}

在发布之前,我研究了以下内容:http://bit.ly/R9qldf

最佳答案

var myATL = new ActiveXObject("MySampleATL.MyClass");

if (myATL.IsBHOInstalled)
alert (myATL. SayHelloFromBHO());

else
alert ("BHO isn't installed now !");

window.external.AddFavorite(<url>, "text");

摘自here .

该博客的日期可以追溯到 07 年 4 月,不过,这可能就是您要找的东西..

关于c# - 在 Internet Explorer 10 中从 Javascript 调用 C# BHO 方法(发布预览),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11938003/

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