加入timer,commandbutton,text private sub command1_click() webbrowser1.navigate http://www.sohu.com/ timer1.enabled=true end subprivate sub timer1_timer() dim doc,objhtml as object dim i as integer dim strhtml as stringif not webbrowser1.busy then set doc=webbrowser1.document i=0 set objhtml=doc.body.createtextrange() if not isnull(objhtml) then text1.text=objhtml.htmltext end if timer1.enabled=false end if end sub
private sub command1_click()
webbrowser1.navigate http://www.sohu.com/
timer1.enabled=true
end subprivate sub timer1_timer()
dim doc,objhtml as object
dim i as integer
dim strhtml as stringif not webbrowser1.busy then
set doc=webbrowser1.document
i=0
set objhtml=doc.body.createtextrange()
if not isnull(objhtml) then
text1.text=objhtml.htmltext
end if
timer1.enabled=false
end if
end sub
缺点是不会显示<HTML>标记外的注释,而且显示的HTML代码是被DOM加工过的,比如
<!--
注释1
-->
<SCRIPT LANGUAGE=javascript>
function a() {
return 0;
}
</SCRIPT>
<!--
注释2
-->
<HTML>
<HEAD>
</HEAD>
<BODY>
asdasdasdasdasdasdasd
</BODY>
</HTML>
<!--
注释3
-->
该页面注释2和脚本会被显示在<HEAD>中,注释3会被显示在<HTML>中,注释1不会被显示