Firefox中利用javascript调用本地程序
http://blog.csdn.net/jensonhjt/article/details/1765557
上面的代码,执行未加参数的程序;下面的代码,执行添加了参数的程序。
阅读(2904) | 评论(0) | 转发(0) |
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
<script>
function hello () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("D:/program files/foobar2000/foobar2000.exe");
file.launch();
}
script>
function hello () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("D:/program files/foobar2000/foobar2000.exe");
file.launch();
}
script>
上面的代码,执行未加参数的程序;下面的代码,执行添加了参数的程序。
function hello() {
var oURL = "www.baidu.com";
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var process = Components.classes['@mozilla.org/process/util;1'].getService(Components.interfaces.nsIProcess);
var targetFile = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
targetFile.initWithPath("D:/temp/1.exe");
process.init(targetFile);
var arguments = [oURL]; //arguments参数必须是数组,否则下面语句不执行
process.run(false, arguments, arguments.length,{});
}
var oURL = "www.baidu.com";
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var process = Components.classes['@mozilla.org/process/util;1'].getService(Components.interfaces.nsIProcess);
var targetFile = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
targetFile.initWithPath("D:/temp/1.exe");
process.init(targetFile);
var arguments = [oURL]; //arguments参数必须是数组,否则下面语句不执行
process.run(false, arguments, arguments.length,{});
}
相关热门文章
给主人留下些什么吧!~~
评论热议