簡體   English   中英

為什么腳本不起作用/ Web瀏覽器(控件/組件)中未按下按鈕?

[英]Why the script does not work / the button is not pressed in the web browser (control/component)?

我寫了兩個程序。 一個在Delphi 2009上,另一個在Visual Studio 2019上以查看相同的html頁面。 我使用了twebbrowser組件(或webbrowser控件)。 在這兩種情況下,單擊webbrowser窗口中頁面上的按鈕均無效,並且相應的Java腳本也不會執行。 該頁面顯示一條消息,說明我的瀏覽器已過期。 嘗試按按鈕編程失敗(沒有任何反應,也沒有錯誤)。 但是該按鈕可以在Internet Explorer 11中使用。該按鈕的代碼:

<div id="showAll" class="showAllClass block" onclick="showAll(1, this)">
  <a href="javascript:void(0);">Show all</a>
</div>

Delphi的代碼:

var
  A : IHTMLElement3;
  doc : IHTMLDocument3;
  v   : OleVariant;
begin
  A := (MyWebbrowser.Document as IHTMLDocument3).getElementById('showAll') as IHTMLElement3;
  v:=Unassigned;
  (A as IHTMLElement3).FireEvent('onclick',v);
end;

C#的代碼:

webBrowser1.Document.GetElementById("showAll").InvokeMember("onclick");

我在這里找到答案如何獲取WebBrowser控件以顯示現代內容? 作為附加

"YourApplicationFileName.exe"=dword:00002af9
"YourApplicationFileName.vshost.exe"=dword:00002af9

通過路徑到注冊表

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

暫無
暫無

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

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