Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 简化强迫IE11在google chrome中打开链接的JS_Javascript_Html_Url - Fatal编程技术网

Javascript 简化强迫IE11在google chrome中打开链接的JS

Javascript 简化强迫IE11在google chrome中打开链接的JS,javascript,html,url,Javascript,Html,Url,我在这里的一篇文章中有一条捷径,解释了如何组合下面的代码,使我更容易在多链接上使用它 我们的公司(目前正迫使我们使用IE11),我需要能够添加一个链接到一个在谷歌chrome中打开的网页。我的密码是: <script type="text/javascript"> function openURL1() { var shell = new ActiveXObject("WScript.Shell"); shell.run("Ch

我在这里的一篇文章中有一条捷径,解释了如何组合下面的代码,使我更容易在多链接上使用它

我们的公司(目前正迫使我们使用IE11),我需要能够添加一个链接到一个在谷歌chrome中打开的网页。我的密码是:

<script type="text/javascript">
    function openURL1()
        {
        var shell = new ActiveXObject("WScript.Shell");
        shell.run("Chrome https://hotmail.com/");
        }
        function openURL2()
        {
        var shell = new ActiveXObject("WScript.Shell");
        shell.run("Chrome https://google.com/");
        }
</script>

<TD COLSPAN="2" STYLE= WIDTH="100"> <input type="button" style ="background-color:grey" onclick="openURL1()" value="Support Net"></TD>
<TD COLSPAN="2" STYLE= WIDTH="100"> <input type="button" style ="background-color:grey" onclick="openURL2()" value="Communities"></TD>

函数openURL1()
{
var shell=新的ActiveXObject(“WScript.shell”);
shell.run(“Chromehttps://hotmail.com/");
}
函数openURL2()
{
var shell=新的ActiveXObject(“WScript.shell”);
shell.run(“Chromehttps://google.com/");
}

只想显示链接,点击即可。我不需要做任何事情,但我有几个链接,我需要添加。HTML代码我可以用自己的方式工作,但对于JS,我仍然是一个新手,仍然很挣扎。干杯

如果我正确阅读了您的请求,您正在寻找类似以下内容:

function openURL(url) {
  let shell = new ActiveXObject("WScript.Shell");
  shell.run("Chrome " + url);
}
使用url作为参数的单个函数,以便可以重用它

当前示例后面的Html正文部分:

<TD COLSPAN="2" STYLE="WIDTH: 100;"> <input type="button" style ="background-color:grey;" onclick="openURL('https://hotmail.com/')" value="Support Net"></TD>
<TD COLSPAN="2" STYLE="WIDTH: 100;"> <input type="button" style ="background-color:grey;" onclick="openURL('https://google.com/')" value="Communities"></TD>
<TD COLSPAN="2" STYLE="WIDTH: 100;"> <input type="button" style ="background-color:grey;" onclick="openURL('https://stackoverflow.com/')" value="Helpful People"></TD>


那么是否将链接传递给函数?基本字符串concatenation@epascarello你能告诉我怎么做吗?我可以不用这个按钮吗?函数openUrl(url){shell.run(“Chrome”+url);}cheers@partylich是的,看起来很熟悉。现在,我如何在html正文中的链接中使用它?有没有一种方法不使用按钮?改为使用链接?
onclick
属性应可用于任何html元素。因此,您选择的元素类型(按钮、链接或其他)没有太多技术限制。