Html 如何使用 VBScript 单击网页上的链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18593499/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 12:59:21  来源:igfitidea点击:

How to click a Link on a webpage using VBScript

htmlinternet-explorervbscript

提问by Ganeshja

Actually i have to click on a link and as a result it will be give two menu list in that i need to select any of those

实际上我必须点击一个链接,结果它会给出两个菜单列表,我需要选择其中的任何一个

here is my VBScript for launching IE and navigate to required web adress

这是我用于启动 IE 并导航到所需 Web 地址的 VBScript

Dim URL 
Dim IE 
Set IE = CreateObject("internetexplorer.application")
URL = "http://it-asg.uhc.com/sites/gcas/pcas/archive/PCR/IVM/modlist/Lists/ElementTracker/AllItems.aspx" 
IE.Visible = True
IE.Navigate URL

Can any any one help me out to click on that link and select any one of those menu source for the link

任何人都可以帮助我单击该链接并为该链接选择任何一个菜单源

Actual source for the link :

链接的实际来源:

<a id="zz13_ListActionsMenu" accesskey="C" href="#" onclick="javascript:return false;" style="cursor ointer;white-space:nowrap;" onfocus="MMU_EcbLinkOnFocusBlur(byid('zz8_RptControls'), this, true);" onkeydown="MMU_EcbLinkOnKeyDown(byid('zz8_RptControls'), MMU_GetMenuFromClientId('zz13_ListActionsMenu'), event);" oncontextmenu="this.click(); return false;" menutokenvalues="MENUCLIENTID=zz13_ListActionsMenu,TEMPLATECLIENTID=zz8_RptControls" serverclientid="zz13_ListActionsMenu">Actions<img src="/_layouts/images/blank.gif" border="0" alt="Use SHIFT+ENTER to open the menu (new window)."></a>

Thanks in advance

提前致谢

回答by Sudhir

For this scenario you can use the method "getElementById". For example:

对于这种情况,您可以使用“getElementById”方法。例如:

IE.Document.getElementById("zz13_ListActionsMenu").Click

So your code will look something like:

所以你的代码看起来像:

Dim URL 
Dim IE 
Set IE = CreateObject("internetexplorer.application")
URL = "http://it-asg.uhc.com/sites/gcas/pcas/archive/PCR/IVM/modlist/Lists/ElementTracker/AllItems.aspx" 
IE.Visible = True
IE.Navigate URL


 Do While IE.Busy
    WScript.Sleep 100
 Loop

IE.Document.getElementById("zz13_ListActionsMenu").Click

There are also other methods you can use to access and click elements on a page, I refer to the following for a list:

您还可以使用其他方法来访问和单击页面上的元素,我参考以下列表:

http://msdn.microsoft.com/en-us/library/ie/ms535862(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library/ie/ms535862(v=vs.85).aspx