本文介绍了VBScript使用生成的URL启动Internet Explorer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

目前,我正在学习HTA编程.我有如下要求.

Currently I'm a learning HTA programming. I have a requirement as follows.

表单中有两个输入框(均为必填).当我输入值并单击搜索按钮时,将根据输入内容创建一个URL.会使用生成的url启动Internet Explorer应用程序.

There are two input boxes in the form (both are mandatory). When I enter the values and click on search button, a url would be created based on the inputs. The should launch the Internet Explorer application with the generated url.

我的问题是我可以启动IE浏览器,但无法将URL传递给它.我已经尝试了很多方法,但无法完成.

My issue is that I'm able to launch IE browser but I'm not able to pass the url to it.I have tried many ways but I'm not able to get it done.

我在下面给出了我的代码.我已经删除了将URL传递给浏览器的错误语法.下面的代码将创建URL并启动一个空白的IE资源管理器.

I have the given my code below. I have removed my erroneous syntax of passing the url to the browser. The below code would create the url and launch a blank IE explorer.

请帮助我.预先感谢.

<html>
<head>
<script language="VBScript">

    Sub RunProgram
        callb = document.getElementById("callb").value
        call = document.getElementById("call").value
        url = "www.google.com"&callb&"and"&call
        msgbox(url)
        Set objShell = CreateObject("Wscript.Shell")
        objShell.Run "iexplore.exe"
    End Sub

</script>
</head>
<body>

<form style="width:254px; height:44px;">
CallB: <input type="text" id="callb" value=""><br>
Call  : <input type="text" id="call" value=""><br><br>
<button onclick="RunProgram">search</button>
</form>

</body>
</html>

推荐答案

您可以使用WShell的Run()方法在默认浏览器中加载URL:

You can load a URL in the default browser by using the Run() method of WShell:

CreateObject("WScript.Shell").Run "www.google.com"

如果要在Internet Explorer中显式加载URL,则需要首先确定IEXPLORE.EXE的完整路径,然后将其传递给Run():

If you want to explicitly load the URL in Internet Explorer, you'll need to determine the full path to IEXPLORE.EXE first, then pass it to Run():

CreateObject("WScript.Shell").Run """" & strExePath & """ www.google.com"

CreateObject("WScript.Shell").Run """" & strExePath & """ " & strURL

请注意引号.您需要在IE的路径两边加上引号,以防路径中包含空格.为了在字符串中指定引号,您必须将其加倍.如果引号令人困惑,则可以使用Chr(34)指定引号字符:

Note the quotes. You'll want to put quotes around the path to IE in case the path contains a space. In order to specify a quote within a string, you have to double it. If the quotes are confusing, you can use Chr(34) to specify a quote character:

CreateObject("WScript.Shell").Run Chr(34) & strExePath & Chr(34) & " " & strURL

这篇关于VBScript使用生成的URL启动Internet Explorer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 15:26