[英]How to open HTML link and click button?
在工作中,我們每天早上必須啟動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上找到更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.