如何在 HTA 的默认 Web 浏览器中打开链接? [英] How can I open a link in the default web browser from an HTA?

查看:35
本文介绍了如何在 HTA 的默认 Web 浏览器中打开链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm working on an application that is implemented as an HTA. I have a series of links that I would like to have open in the system's default web browser. Using <a href="url" target="_blank"> opens the link in IE regardless of the default browser.

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

Is there a way to use the default browser? Using JavaScript is an option.

推荐答案

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

Create a shell and attempt to run a URL.

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

This works for me (save as whatever.hta and execute it) on my system. Clicking on the button opens Google in Firefox:

<!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>

这篇关于如何在 HTA 的默认 Web 浏览器中打开链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆