下面是一个浏览器,实现到HTTP://onlinefamily.norton.com 那里自动填写不准浏览的网站,请帮我看看哪里错了,按了BUTTON没反应,我是VS 2005using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace autofillform
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://onlinefamily.norton.com");
} private void button1_Click(object sender, EventArgs e)
{
HtmlElement element = webBrowser1.Document.GetElementById("newBlockUrl");
element.SetAttribute("value", "WWW.163.COM");
webBrowser1.Document.All["blockListBtn"].InvokeMember("Click"); }
}
}http://onlinefamily.norton.com 设置的屏蔽网站的HTML
<label for="newBlockUrl" class="" style="text-align: left; padding-left: 10px; width: 100%; padding-bottom: 6px;">输入网站</label>
<input class="fs_inpleft" id="newBlockUrl" name="newBlockUrl" autocomplete="off" style="width: 240px;" maxlength="100" type="text"><button id="blockListBtn" type="button" class="btn-yellow-small" onclick="thisPage.addToBlockList(); return false;" style="float: right; margin-right: 10px;">
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace autofillform
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://onlinefamily.norton.com");
} private void button1_Click(object sender, EventArgs e)
{
HtmlElement element = webBrowser1.Document.GetElementById("newBlockUrl");
element.SetAttribute("value", "WWW.163.COM");
webBrowser1.Document.All["blockListBtn"].InvokeMember("Click"); }
}
}http://onlinefamily.norton.com 设置的屏蔽网站的HTML
<label for="newBlockUrl" class="" style="text-align: left; padding-left: 10px; width: 100%; padding-bottom: 6px;">输入网站</label>
<input class="fs_inpleft" id="newBlockUrl" name="newBlockUrl" autocomplete="off" style="width: 240px;" maxlength="100" type="text"><button id="blockListBtn" type="button" class="btn-yellow-small" onclick="thisPage.addToBlockList(); return false;" style="float: right; margin-right: 10px;">
但是网页是fs,用https
我后来修改了 private void button1_Click(object sender, EventArgs e)
{
HtmlElement element = webBrowser1.Document.GetElementById("newBlockUrl");
element.InnerText="113.105.246.90";
HtmlElement submit = webBrowser1.Document.GetElementById("blockListBtn");
submit.InvokeMember("click"); }
那个网页的HTML <label for="newBlockUrl" class="" style="text-align: left; padding-left: 10px; width: 100%; padding-bottom: 6px;">输入网站</label>
<div style="clear: both; padding-bottom: 0px;">
<div class="fs_inp">
<div class="fs_inpright">
<input class="fs_inpleft" id="newBlockUrl" name="newBlockUrl" autocomplete="off" style="width: 240px;" maxlength="100" type="text">
</div>
</div>
<span style="display: none;" class=" error" id="newBlockUrl_error"></span> </div>
<span id="newBlockUrl_msg" style="float: right; color: red; padding: 5px 20px 0pt 11px;"> </span>
<div id="blockListButton" style="float: right; clear: both; margin-top: 10px; width: 100%;">
<img src="SettingsHome.fs2_files/icon-help_002.gif" alt="" style="cursor: help; float: right; padding-top: 3px; margin-right: 15px;" id="help_tooltip_BlockUrl" class="ttNode">
<button id="blockListBtn" type="button" class="btn-yellow-small" onclick="thisPage.addToBlockList(); return false;" style="float: right; margin-right: 10px;">
<span><b>添加到列表</b></span>
</button>