我試圖在文本框中插入文本到瀏覽器中,但是我有問題要做。將文本插入到瀏覽器中的文本框中
我正在嘗試此代碼。
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("192.168.10.1")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.Document.GetElementById("nmgp_arg_fast_search").Focus()
WebBrowser1.Document.GetElementById("nmgp_arg_fast_search").InnerText = TextBox2.Text()
End Sub
以下錯誤計提壞賬:
對象引用不設置到對象的實例。
Ι是文本框的確定名稱爲「nmgp_arg_fast_search」,因爲Ι我試圖在www.google.com代碼和文件名稱爲「Q」和它的工作。
,這是我從螢火蟲得到(編輯:如果我使用Firebug的Mozilla Firefox瀏覽器檢查,我可以看到所有代碼)
<td class="scGridToolbarPadding" width="33%" valign="middle" nowrap="" align="left">
<script type="text/javascript">
var change_fast_top = "";
</script>
<input type="hidden" value="SC_all_Cmp" name="nmgp_fast_search">
<input type="hidden" value="qp" name="nmgp_cond_fast_search">
<script type="text/javascript">
var scQSInitVal = "";
</script>
<span id="quicksearchph_top">
<input id="SC_fast_search_top" class="css_toolbar_obj" type="text" alt="{watermark:'Pencarian cepat', watermarkClass:'css_toolbar_objWm', maxLength: 255}" onchange="change_fast_top = 'CH';" size="30" value="" name="nmgp_arg_fast_search" style="vertical-align: middle; height: 16px; padding-right: 17px; display: none;" maxlength="255">
<input id="SC_fast_search_top" class="css_toolbar_obj css_toolbar_objWm" type="text" alt="{watermark:'Pencarian cepat', watermarkClass:'css_toolbar_objWm', maxLength: 255}" onchange="change_fast_top = 'CH';" size="30" value="" name="sc_clone_nmgp_arg_fast_search" style="vertical-align: middle; height: 16px; padding-right: 17px;" maxlength="255">
<img id="SC_fast_search_close_top" onclick="document.getElementById('SC_fast_search_top').value = '';document.F0_top.nmgp_opcao.value='fast_search';document.F0_top.submit();" src="/cts2_pn/_lib/img/scriptcase__NM__qs_close.png" style="display: none; right: 5px; cursor: pointer;">
<img id="SC_fast_search_submit_top" onclick="scQuickSearchSubmit_top();" src="/cts2_pn/_lib/img/scriptcase__NM__qs_lupa.png" style="right: 5px; cursor: pointer;">
</span>
但是,當我從webbrowser1看到很多隱藏代碼,我找不到元素..這就是爲什麼我總是得到錯誤..
我發現這個問題,但仍然沒有解決我的問題..
對於遲到的評論感到抱歉,我正在嘗試你的代碼,但仍然沒有運氣.. :( – CrazyThink 2014-10-01 06:16:38