最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
在NET中控制HTML元素
时间:2008-05-27 编辑:简简单单 来源:一聚教程网
Form mshtml.HTMLFormElementClass
IHTMLDocument2 mydocument=(IHTMLDocument2)web.Document;
按件[按件]:IHTMLElement元素
object obj1 = mydocument.all.item("UG", 0);
if (obj1 is IHTMLElement)
{
((IHTMLElement) obj1).click();
}
object obj1 = mydocument.all.item("BetList", 0);
if (obj1 is IHTMLElement)
{
datatext.Text=((IHTMLElement) obj1).innerText;
}
输入[输出入件]:IHTMLInputElement元素
object obj1 = mydocument.all.item("username", 0);
if (obj1 is IHTMLInputElement)
{
((IHTMLInputElement) obj1).value ="设置用户名值";
}
窗体frame:HTMLFrameElementClass
object obj1 = mydocument.all.item("main",0);
if (obj1 is HTMLFrameElementClass)
{
obj1=(HTMLFrameElementClass) obj1;
}
在指定的框中打开新页:frame
object obj1 = mydocument.all.item("main",0);
if (obj1 is HTMLFrameElementClass)
{
((HTMLFrameElementClass) obj1).contentWindow.window.execScript("document.location=''http://"+host+"/en-lang/underover/main.asp?t=l'';","javascript");
}
获取指定的框并获取指的元素值及源码和框中frame的源网址
object obj1 = mydocument.all.item("main",0);
if (obj1 is HTMLFrameElementClass)
{
object obj2 = ((HTMLFrameElementClass) obj1).contentWindow.document.all.item("BetList", 0);
if (obj2 is IHTMLElement)
{
datatext.Text=((IHTMLElement) obj2).innerText;//元素值
datatext.AppendText(((IHTMLElement) obj2).innerHTML);//源码
datatext.AppendText(((HTMLFrameElementClass) obj1).contentWindow.location.href);//框中的源网址
}
}
这类框架:iframe
HTMLIFrameClass
object obj2 = ((HTMLFrameElementClass) obj1).contentWindow.document.all.item("maintt", 0);
object obj3 = ((mshtml.HTMLIFrameClass) obj2).contentWindow.document.all.item("BetList", 0);
if (obj3 is IHTMLElement)
{
datatext.Text=((IHTMLElement) obj3).innerText;
//datatext.AppendText(((IHTMLElement) obj2).innerHTML);
datatext.AppendText(urlstr);
}
document.formname.action=parent.yourpage;
-
上一个: 获取HTML中的父控件方法
-
下一个: 继承有参数的构造函数
相关文章
- HTML设计元素介绍 HTML有哪些元素 05-04
- HTML5 新增和移除元素命令介绍 03-03
- HTML5中新增的结构元素介绍 12-25
- HTML5 新增元素与属性用法介绍 12-05
- IE中HTML元素的一些特殊的“性质” 01-26
- C#复制数组的两种方式及效率比较解读 10-24
热门栏目
-
php教程
php入门 php安全 php安装 php常用代码 php高级应用 -
asp.net教程
基础入门 .Net开发 C语言 VB.Net语言 WebService -
手机开发
安卓教程 ios7教程 Windows Phone Windows Mobile 手机常见问题 -
css教程
CSS入门 常用代码 经典案例 样式布局 高级应用 -
网页制作
设计基础 Dreamweaver Frontpage js教程 XNL/XSLT -
办公数码
word excel powerpoint 金山WPS 电脑新手 -
jsp教程
Application与Applet J2EE/EJB/服务器 J2ME开发 Java基础 Java技巧及代码