通过javascript执行wsh代码的html代码

通过javascript执行wsh代码的html代码,javascript,html,wsh,Javascript,Html,Wsh,我被这段代码困住了……我正试图让html页面进入,当你点击链接,调用bms函数,它应该打开internet explorer,转到google,并在搜索文本框中填入单词“test”。这不是我想要使用的网站或单词,但我需要更改它,因为实际的网站/单词是敏感信息。我想通过IE来使用它,因为我们的流程要经过这个浏览器,特别是使用-nomerge函数。我的代码如下。谢谢你的帮助 <html> <head> <script> var WshShell = new

我被这段代码困住了……我正试图让html页面进入,当你点击链接,调用bms函数,它应该打开internet explorer,转到google,并在搜索文本框中填入单词“test”。这不是我想要使用的网站或单词,但我需要更改它,因为实际的网站/单词是敏感信息。我想通过IE来使用它,因为我们的流程要经过这个浏览器,特别是使用-nomerge函数。我的代码如下。谢谢你的帮助

<html>
<head>    
<script>
var WshShell = new ActiveXObject("WScript.Shell");
function BMS()
{
WshShell.Run("iexplore.exe -nomerge http://google.com");
WScript.Sleep (5000);
WshShell.SendKeys ("test");
WScript.Quit();
}
</script>
</head>
<a href="#" onclick="javascript:BMS();">BMS</a>
<br /><br />
<a href="#" onclick="javascript:DAY();">DAY</a>
</html>​

var WshShell=newActiveXObject(“WScript.Shell”);
函数BMS()
{
运行(“iexplore.exe-nomergehttp://google.com");
WScript.Sleep(5000);
WshShell.SendKeys(“测试”);
WScript.Quit();
}



不要被翡翠扔掉;只是更快。请注意,我将脚本放在结束正文标记之前

html
  head
    title foo
  body // body tag added
    p notice that i've not declared script yet. Preference/good practice.
    a#bsdTrigger(href='#') foo    
    a#ssddTrigger(href='#') bar
    //- scripte here
重要的部分是:
我希望这有帮助。。。这是一个非常通用和精心设计的方法,但在做你想做的事情时,你会使用完全相同的方法。

你不需要在onclick值前面加上javascript,但我不确定这是否会有任何影响。。。虽然你好像错过了身体标签。所以,我会做一些类似于我的答案。。。输入文字是一项真正的要求吗?为什么不在URL中添加一个查询字符串来匹配Google表单提交的内容呢?我实际上不需要向搜索引擎查询,我这样做是因为我不能输入敏感信息,所以我对脚本做了一些修改。我正在寻找一种方法,我可以编辑/使用,而不是实际去谷歌键入“测试”我不知道发生了什么事,“这是一支笔”链接,但它不再工作,我不能查看任何东西,我也不能让这个代码工作。你又是怎么弄到的?
 (function() {
    // now the variable will not pollute your global ns
    var WshShell = {}; //ignore the OR only because there is no Active thing

    WshShell.log = function() { // fake behavior for testing
        console.log(arguments);
    } 

    var bsd = function BSD() {
        WshShell.log("foo");
        window.alert('foo!');
        return false;
    }

    document.getElementById("bsdTrigger").addEventListener('click', bsd);
})();