我在Delphi XE7(win7,Internet Explorer 9)中使用TWebBrowser
組件來填充網頁中的表單。當訪問WebBrowser1.OleObject.Document.getElementById('Inputname')時出現無效的Variant操作錯誤。setAttribute
下面是HTML:
<input name="login" class="form-control" id="inputLogin" placeholder="Username" type="text">
我使用這個代碼:
WebBrowser1.OleObject.Document.getElementById('InputLogin').setAttribute('value','sometext');
它在我的電腦上的偉大工程,但其他電腦上它給我這個錯誤:
Invalid Variant Operation error.
我該如何解決這個問題?
我的猜測是,其他PC缺少DLL。它可以是你自己的Delphi項目或瀏覽器組件所需的MS DLL。另一臺PC是否有不同的瀏覽器版本? - 另外,document.getElementById是區分大小寫的 - >您的ID不是大寫字母'Input ....' – Thor