简体   繁体   English

如何打开HTML链接并单击按钮?

[英]How to open HTML link and click button?

At work we have 7 tools that I have to launch every morning. 在工作中,我们每天早上必须启动7个工具。 All the tools are on web pages. 所有工具都在网页上。

So I have to open 7 links and click several buttons to launch the tools. 因此,我必须打开7个链接,然后单击几个按钮以启动工具。

I would like to automate this operation. 我想自动执行此操作。 I used a C# code (similar to this one) which works fine 我使用了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();
    }
}

But actually we are not allowed anymore to use C# for licence reasons... 但是实际上,出于许可原因,我们不再被允许使用C#...

Is there any way to do that in HTML/Javascript ? 有没有办法在HTML / Javascript中做到这一点? (Open a link and click a button on it) (打开一个链接,然后单击它上的一个按钮)

I'm not asking someone to do the work for me, but if you just have a nice tutorial or tip to look at it will be great. 我不是要别人为我做这项工作,但是如果您只是有一个不错的教程或技巧提示,那将是很棒的。

Thank you. 谢谢。

You can use Javascript and use 您可以使用Javascript并使用

window.open("www.url.com","_self")

to open the links. 打开链接。

You can find more info on window.open @ http://www.w3schools.com/jsref/met_win_open.asp 您可以在window.open @ http://www.w3schools.com/jsref/met_win_open.asp上找到更多信息

您可以将浏览器设置在启动时将其全部7作为主页打开

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM