所以我試圖模擬鏈接單擊按鈕時單擊,但沒有什麼似乎在執行代碼時發生。模擬鏈接點擊功能,指向本地主機
<a id=「preface」 href=https://localhost:443/6.5.1> 6.5.1 </a>
<button id=「auto」 onclick="myFunction()">Click</button>
<script>
function myFunction() {
document.getElementById(「preface」).click();
}
</script>
我應該指出,在使用和Golang與執行包含此代碼模板文件:
s1, _ := template.ParseFiles("html_file")
s1.ExecuteTemplate(w, "html_file", nil)
我不知道爲什麼它不工作,因爲當我嘗試做一個警報動作它的工作原理,即使我嘗試打開www.google.com窗口它不起作用。
您是否嘗試將https:// localhost:443/6.5.1放在引號中?即。 'href =「https:// localhost:443/6.5.1」' – FrankerZ
@FrankerZ我做過,但如果我這樣做,那麼甚至不用手動點擊鏈接工作了。 –