如何点击网页对话框的按钮

星云飞龙 2010-11-10 10:00:45
对话框的部分代码如下:

<SCRIPT type=text/javascript></SCRIPT>

<TABLE height=22 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD class=tab_bar noWrap width="10%">员工编辑</TD>
<TD id=staffEditTable.modifyPassword style="DISPLAY: block" align=right><INPUT class=button id=staffEditTable.activePartyRoleBtn onclick=activePartyRole(); type=button value=激活员工号> <INPUT class=button_key onclick=modifyPass(); type=button value=重置口令> </TD></TR></TBODY></TABLE></TD>
<TD width=5 height=22><IMG height=22 src="../images/table/tab_blue_bar_right.gif" width=5></TD></TR><INPUT type=hidden value=830108983 name=staffEditTable.partyRoleId>
<TR class=tab_blue_color vAlign=top>
<TD align=middle colSpan=3>
<TABLE cellSpacing=1 cellPadding=2 width="100%" border=0>
<TBODY>
<TR>
<TD class=td_txt width="13%">员工号 </TD>
<TD width="20%"><INPUT onkeypress=onKeypressForLetterAndNumber() id=staffEditTable.staffCode onblur=checkLetterAndNumber(); title=员工号 value=734010315 prompt="员工号"><SPAN class=red_point>*</SPAN> </TD>
<TD class=td_txt width="13%">员工描述 </TD>
<TD colSpan=3><INPUT id=staffEditTable.staffDesc title=员工描述 style="WIDTH: 97%" value=张为平><SPAN class=red_point>*</SPAN> </TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD width=5 height=5><IMG height=5 src="../images/table/tab_blue_bottom_left.gif" width=5></TD>
<TD class=tab_blue_color width="100%"><IMG height=5 src="../images/shim.gif" width=5></TD>
<TD width=5 height=5><IMG height=5 src="../images/table/tab_blue_bottom_right.gif" width=5></TD></TR></TBODY></TABLE>
<TABLE id=partyRoleSaveTable cellSpacing=2 cellPadding=5 width="100%" border=0>
<TBODY>
<TR align=middle>
<TD><INPUT class=button id=partyRoleSaveTable.saveButton onclick=savePartyRole(); type=button value="确 定"> <INPUT class=button id=partyRoleSaveTable.clearButton onclick=clearPartyRole(); type=button value="重 置"> <INPUT class=button id=closeButton onclick=closePartyRole(); type=button value="关 闭"> </TD></TR></TBODY></TABLE>
<SCRIPT type=text/javascript>
window.setTimeout("initPage()",2);
</SCRIPT>
如何点击到上面 激活员工号、重置口令、确 定、重 置、关 闭按钮并执行相应代码
...全文
130 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
星云飞龙 2010-11-10
  • 打赏
  • 举报
回复
是WINFORM的WEBBROWSE的一个对话弹出框,代码是获取窗口句柄转化为ITHMLDOCUMENT2得到的,程序的部分代码如下:
WEBBROWSE点击上页按钮弹出窗口代码:
private void button3_Click(object sender, EventArgs e)
{

HtmlDocument objDoc = webBrowser1.Document.Window.Frames["ModelFrame"].Document;
objDoc.GetElementById("partyRoleTree").Parent.Document.InvokeScript("editPartyRoleFun");
}
//获取弹出窗口代码
private void button5_Click(object sender, EventArgs e)
{
IntPtr hd = FindWindow("Internet Explorer_TridentDlgFrame", "参与人角色 -- 网页对话框");
while (hd != IntPtr.Zero) //工号存在
{

int lngMsg = 0;
int lRes;
IntPtr hchild = FindWindowEx(hd, IntPtr.Zero, "Internet Explorer_Server", String.Empty);


if (!hchild.Equals(IntPtr.Zero))
{
lngMsg = RegisterWindowMessage("WM_HTML_GETOBJECT");
if (lngMsg != 0)
{
SendMessageTimeout(hchild, lngMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, out lRes);
if (!(bool)(lRes == 0))
{
int hr = ObjectFromLresult(lRes, ref IID_IHTMLDocument, 0, ref document);
if ((bool)(document == null))
{
MessageBox.Show("No IHTMLDocument Found!", "Warning");
}
else
{
richTextBox1.Text = document.parentWindow.document.body.innerHTML;
richTextBox1.Text += document.location.ToString();
richTextBox1.SaveFile("temp.html", RichTextBoxStreamType.PlainText);
}
}

}


}
}
}

}
星云飞龙 2010-11-10
  • 打赏
  • 举报
回复
在WINFORM中是个弹出的对话框,怎么能获取DOCUMENT,最多只能获取ITHMLDOCUMENE2,代码是从ITHMLDOCUME2获取的
liuwei2500 2010-11-10
  • 打赏
  • 举报
回复
document.getElementById("staffEditTable.staffCode").focus();
其他的都一样,获取焦点

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧