'引用internet control控件 '引用html object对象 Private Sub Form_Load() Dim html As New HTMLDocument Dim i As Integer ie.Navigate "d:\3.htm" Set html = ie.Document For i = 0 To html.frames.length - 1 GetImagSrc html.frames(i).Document Next End Sub Private Sub GetImagSrc(doc As Object) Dim i As Integer Dim frmhtml As HTMLDocument Set frmhtml = doc Debug.Print frmhtml.location For i = 0 To frmhtml.images.length - 1 Debug.Print frmhtml.images(i).src Next End Sub 网页3.htm <html><head> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>New Page 2</title> </head><frameset rows="64,*"> <frame name="header" scrolling="no" noresize target="main" src="1.htm"> <frame name="main" src="2.htm"> <noframes> <body> <p>此网页使用了框架,但您的浏览器不支持框架。</p> </body> </noframes> </frameset></html>'网页2的内容 <a href = 'http://www.sina.com.cn'>sina</a> <img border="0" src="1.bmp"></p> <img border="0" src ="2.bmp">
不是FRAME标签,是IFRAME标签。
不是FRAME标签,是IFRAME标签。
'不好意思昨天说错了,iframe还是用frames,程序如下 Private Sub Form_Load() Dim html As New HTMLDocument Dim i As Integer ie.Navigate "d:\1.htm" Set html = ie.Document For i = 0 To html.frames.length - 1 GetImagSrc html.frames(i).Document Next End Sub Private Sub GetImagSrc(doc As Object) Dim i As Integer Dim frmhtml As HTMLDocument Set frmhtml = doc Debug.Print frmhtml.location For i = 0 To frmhtml.images.length - 1 Debug.Print frmhtml.images(i).src Next End Sub1.htm内容 <IFRAME SRC="frame.htm" STYLE="z-index:1" > </IFRAME> frame.htm内容 <img border='0' src='1.bmp'> <p> <img border ='0' src = '2.bmp'> '输出结果 file:///D:/frame.htm file:///D:/1.bmp file:///D:/2.bmp
呵呵
'引用html object对象
Private Sub Form_Load()
Dim html As New HTMLDocument
Dim i As Integer
ie.Navigate "d:\3.htm"
Set html = ie.Document
For i = 0 To html.frames.length - 1
GetImagSrc html.frames(i).Document
Next
End Sub
Private Sub GetImagSrc(doc As Object)
Dim i As Integer
Dim frmhtml As HTMLDocument
Set frmhtml = doc
Debug.Print frmhtml.location
For i = 0 To frmhtml.images.length - 1
Debug.Print frmhtml.images(i).src
Next
End Sub
网页3.htm
<html><head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 2</title>
</head><frameset rows="64,*">
<frame name="header" scrolling="no" noresize target="main" src="1.htm">
<frame name="main" src="2.htm">
<noframes>
<body> <p>此网页使用了框架,但您的浏览器不支持框架。</p> </body>
</noframes>
</frameset></html>'网页2的内容
<a href = 'http://www.sina.com.cn'>sina</a>
<img border="0" src="1.bmp"></p>
<img border="0" src ="2.bmp">
Private Sub Form_Load()
Dim html As New HTMLDocument
Dim i As Integer
ie.Navigate "d:\1.htm"
Set html = ie.Document
For i = 0 To html.frames.length - 1
GetImagSrc html.frames(i).Document
Next
End Sub
Private Sub GetImagSrc(doc As Object)
Dim i As Integer
Dim frmhtml As HTMLDocument
Set frmhtml = doc
Debug.Print frmhtml.location
For i = 0 To frmhtml.images.length - 1
Debug.Print frmhtml.images(i).src
Next
End Sub1.htm内容
<IFRAME SRC="frame.htm" STYLE="z-index:1" >
</IFRAME>
frame.htm内容
<img border='0' src='1.bmp'>
<p>
<img border ='0' src = '2.bmp'>
'输出结果
file:///D:/frame.htm
file:///D:/1.bmp
file:///D:/2.bmp
</IFRAME>这样就不可以了,你试试,它提示:实时错误'-2147024891 (80070005)';
拒绝访问好像IE不允许这样的跨域操作。
去里面检测吧,str=ie.document.body.innerhtml