110,545
社区成员
发帖
与我相关
我的任务
分享
在各个iframe里插入新控件
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("file:///C:/1.htm");
while (webBrowser1.IsBusy) Application.DoEvents();
}
private void button1_Click(object sender, EventArgs e)
{
int iCount = webBrowser1.Document.Window.Frames.Count;
for (int i = 0; i < iCount; i++)
{
HtmlElement ee = webBrowser1.Document.CreateElement("test");
ee.InnerHtml = "<input type='type' value='test'>";
webBrowser1.Document.Window.Frames[i].Document.Body.InsertAdjacentElement(HtmlElementInsertionOrientation.AfterBegin, ee);
}
}
获取各个iframe的源代码
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("file:///C:/1.htm");
while (webBrowser1.IsBusy) Application.DoEvents();
}
private void button1_Click(object sender, EventArgs e)
{
int iCount = webBrowser1.Document.Window.Frames.Count;
for (int i = 0; i < iCount; i++)
{
MessageBox.Show( webBrowser1.Document.Window.Frames[i].Document.Body.InnerHtml);
}
}