簡體   English   中英

在VB.NET中嵌入Javascript

[英]Embed Javascript in VB.NET

我需要在VB.NET中添加javascript代碼的方法;

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.WebBrowser1.Document.InvokeScript("javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://example.com/api.php?p=mail';})();")

我使用此javascript代碼在網站中填寫表單(在帶有書簽的Firefox瀏覽器上)

javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://example.com/api.php?p=mail

現在,我想在VB.Net瀏覽器中使用它,但是當我執行“調用腳本”時,什么也沒發生。 我也嘗試了其他方法,但是沒有去。

嘗試:

 WebBrowser1.Document.parentWindow.execScript "javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://example.com/api.php?p=mail';})();", "JScript" 

參見VBForums ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM