如何在HTA的默认Web浏览器中打开链接?

Joe*_*air 8 javascript browser hta

我正在开发一个作为HTA实现的应用程序.我有一系列链接,我想在系统的默认Web浏览器中打开.<a href="url" target="_blank">无论默认浏览器如何,使用都会在IE中打开链接.

有没有办法使用默认浏览器?使用JavaScript是一种选择.

Jon*_*nan 25

创建一个shell并尝试运行URL.

这对我有用(保存为whatever.hta并执行它)在我的系统上.点击该按钮可在Firefox中打开Goog​​le:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
  <title>HTA Test</title>
  <hta:application applicationname="HTA Test" scroll="yes" singleinstance="yes">
  <script type="text/javascript">
  function openURL()
  {
      var shell = new ActiveXObject("WScript.Shell");
      shell.run("http://www.google.com");
  }
  </script>
</head>
<body>

<input type="button" onclick="openURL()" value="Open Google">

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

  • 这仅在IE中实现时才有效.不在Chrome或Firefox中. (4认同)
  • @Siyah HTA 使用 IE 引擎运行:http://en.wikipedia.org/wiki/HTML_Application#Execution (2认同)