http://social.msdn.microsoft.com/Forums/ie/en-US/40500bc9-e759-4051-a3d6-5fe7c11a2cf6/calling-c-bho-methods-from-javascript?forum=ieextensiondevelopment
解决方案 »
- 100分!!!用Jquery实现全选后能够执行被选中的checkbox脚本事件!
- C#如何显示遥感图像?
- c#里面的变量已经用Trim()去掉空格,但为什么存到数据库中还有空格?
- 为什么C#中要用属性来封装字段有什么好处?我可以把字段声明为私有的,然后用两个public方法来代替get,set块啊!!!!(多谢了!)
- 如何在C#中定义结构体数组?
- 怎样将图片转成二进制并写入到文本文件中
- 分只有这么多了,高手帮帮忙,关于http协议的基础问题
- 关于sql server数据库连接的问题
- 我想用c#.net做个网页浏览器。怎么我没找到这个控件,高手给个提示。
- ★★★★★如何设置Word表格的列宽?★★★★★
- css+div兼容的教程
- c#连接MS SQL SERVER哪种方法最快又稳定
按照上面这样做了,悲催的是不是每次都成功,debug发现
dynamic window = m_WebBrowser.Document.parentWindow;
System.Runtime.InteropServices.Expando.IExpando windowEx = (System.Runtime.InteropServices.Expando.IExpando)window;
windowEx.AddProperty("myExtension");
window.myExtension = this;转换IExpando时有时候抛DBNUll,十次基本九次如此,还有别的方法没?
试试这个
HTMLDocument document = (HTMLDocument)this.Explorer.Document;
IExpando windowEx = (IExpando)document.parentWindow;
PropertyInfo MyExtension = windowEx.GetProperty("LGSoft_TB", BindingFlags.Default);
if (MyExtension == null) MyExtension = windowEx.AddProperty("LGSoft_TB");
MyExtension.SetValue(windowEx, this, null);
原文章来源[大家站社区](http://www.dajiaz.com)原文出处:http://www.dajiaz.com/program/dotnet/js-call-bho-function.html
function execCommand(command, strArgs)
{
// separate command arguments
var args = new Array();
var quoted = false;
var double_quoted = false;
var param = "";
for (var i = 0; i < strArgs.length; i++) {
var charArgs = strArgs.substring(i,i + 1);
if ( charArgs == "\"" && !quoted ) { double_quoted =! double_quoted; }
else if ( charArgs == "\'" && !double_quoted ) { quoted =! quoted; }
else if ( /\s/.test(charArgs) && !quoted && !double_quoted ) {
if (param != "") args.push( param );
param = "";
} else param += charArgs;
}
if (param != "") args.push( param );
// create a file object for the external program
try {
var applicFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
var applic = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
//var applic = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess2);
applicFile.initWithPath(command);
if (!applicFile.exists()) {
alert("Executable '" + command + "' does not exist.");
} else {
applic.init(applicFile);
applic.run(false, args, args.length);
//applic.runAsync(args, args.length, null, false);
}
} catch (e) {
alert("Cannot run executable: " + e);
return false;
}
}