在工作中,我们有 7 个工具,我每天早上都必须启动它们。所有工具都在网页上。
所以我必须打开 7 个链接并单击几个按钮才能启动这些工具。
我想自动化此操作。我使用了 C# 代码(与此类似),效果很好
SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();
ie.Visible = true;
ie.Navigate("https://www.google.co.in");
//Wait for page to load
while (ie.Busy)
{
Threading.Thread.Sleep(100);
}
dynamic allLinks = ((mshtml.IHTMLDocument3)ie.Document).getElementsByTagName("a");
foreach (mshtml.IHTMLAnchorElement link in allLinks) {
//Do some validation to find out the required link
if (link.href.Contains("https://accounts.google.com/ServiceLogin")) {
link.click();
}
}
但实际上,出于许可原因,我们不再被允许使用 C#...
有什么方法可以在 HTML/Javascript 中做到这一点吗? (打开链接并单击其上的按钮)
我并不是要求别人为我做这项工作,但如果你有一个很好的教程或技巧来看看那就太好了。
谢谢。
最佳答案
您可以使用 Javascript 并使用
window.open("www.url.com","_self")
打开链接。
您可以在 window.open @ http://www.w3schools.com/jsref/met_win_open.asp 上找到更多信息
关于javascript - 如何打开 HTML 链接并单击按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35152697/