473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

WebBrowser1.DocumentText

How can I grab html source of a frame?

I can retrive main frame by WebBrowser1.DocumentText
but I want to retrive inner (child) frame...

WebBrowser1.Document.Window.Frames(0).DocumentText like thing doesn't exist...

Jul 1 '06 #1
16 9897
Nime,

You are number three asking this in this newsgroup. In my idea you cannot do
that with the new webbrowser (it is missing downloadcomplete). You can do it
with the Axwebbrowser. If you only want to get one special frame with its
own URL, than you can as well use this

http://www.vb-tips.com/dbPages.aspx?...f-56dbb63fdf1c

I hope this helps,

Cor


"nime" <ea****@planev.comschreef in bericht
news:eU**************@TK2MSFTNGP02.phx.gbl...
How can I grab html source of a frame?

I can retrive main frame by WebBrowser1.DocumentText
but I want to retrive inner (child) frame...

WebBrowser1.Document.Window.Frames(0).DocumentText like thing doesn't
exist...



Jul 2 '06 #2
On Sun, 2 Jul 2006 02:18:48 +0300, "nime" <ea****@planev.comwrote:
>How can I grab html source of a frame?

I can retrive main frame by WebBrowser1.DocumentText
but I want to retrive inner (child) frame...

WebBrowser1.Document.Window.Frames(0).DocumentTex t like thing doesn't exist...

See if this helps:

Private LinksTable As Hashtable

Private Sub WebBrowser1_DocumentCompleted(ByVal _
sender As Object, ByVal e As _
System.Windows.Forms.WebBrowserDocumentCompletedEv entArgs) _
Handles WebBrowser1.DocumentCompleted

GetLinksFromFrames()

End Sub

Private Sub GetLinksFromFrames()
LinksTable = New Hashtable()
Dim FrameUrl As String

If (Not WebBrowser1.Document Is Nothing) Then
With WebBrowser1.Document
Dim CurrentWindow As HtmlWindow = .Window
If (CurrentWindow.Frames.Count 0) Then
For Each Frame As HtmlWindow In _
Frame.Document.Links
FrameUrl = Frame.Url.ToString()

Dim ThisFrameName As String = Frame.Name
Dim ThisFrameDocument As _
HtmlDocument = Frame.Document

Dim FrameLinksHash As New Hashtable()
LinksTable.Add(FrameUrl, FrameLinksHash)

For Each HrefElement As HtmlElement In _
Frame.Document.Links
FrameLinksHash.Add(HrefElement.GetAttribute _
("HREF"), "Url")
Next
Next
Else
Dim DocLinksHash As New Hashtable()
LinksTable.Add(.Url.ToString(), DocLinksHash)

For Each HrefElement As HtmlElement In .Links
DocLinksHash.Add(HrefElement.GetAttribute _
("HREF"), "Url")
Next
End If
End With
End If
End Sub
Gene
Jul 2 '06 #3
"nime" <ea****@planev.comschrieb:
How can I grab html source of a frame?

I can retrive main frame by WebBrowser1.DocumentText
but I want to retrive inner (child) frame...

WebBrowser1.Document.Window.Frames(0).DocumentText like thing doesn't
exist...
\\\
For Each Frame As HtmlWindow In Me.WebBrowser1.Document.Window.Frames
MsgBox(Frame.Document.All(1).OuterHtml)
Next Frame
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 2 '06 #4
"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
You are number three asking this in this newsgroup. In my idea you cannot
do that with the new webbrowser (it is missing downloadcomplete).
What about this solution?

\\\
Private Sub WebBrowser1_DocumentCompleted( _
ByVal sender As Object, _
ByVal e As WebBrowserDocumentCompletedEventArgs _
) Handles WebBrowser1.DocumentCompleted
If Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
MsgBox("Document and frames loaded!")
End If
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 2 '06 #5
Thank you for your valuable responses.

I am currently using WebBrowser control to automate a few things like auto-login a site, etc.
I don't know what is the difference between Navigated and DocumentComplete events, plus
in my application, DocumentComplete event never fired yet... Then I used Navigated instead.
But the problem is that the document is incomplete. I've examined Document.body.innerHTML
and only a part of the source appears...

Private Sub WebBrowser1_Navigated(...)

Select Case e.Url.ToString

Case "http://www.domain.com/"

''''ProcessMainPage() ' Do nothing

Case "http://www.domain.com/login.asp" 'Login frame

ProcessLoginPage()

End Select

End Sub

Private Sub ProcessLoginPage()

Dim frm as HTMLDocument
Dim el as HTMLElement

For i = 0 To WebBrowser1.Document.Window.Frames.Count - 1

'Find the login frame
If WebBrowser1.Document.Window.Frames(i).Document.Win dow.Url.ToString = "http://www.domain.com/login.asp" Then
frm = WebBrowser1.Document.Window.Frames(i).Document

'Fill the form
For Each el In frm.Forms
Select Case el.Name
Case "login"
el.InnerText = "username"
Case "pass"
el.InnerText = "secret"
End Select
Next el

End If

Next i

End Sub
Jul 2 '06 #6
This event never fired here : (

"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
>You are number three asking this in this newsgroup. In my idea you cannot do that with the new webbrowser (it is missing
downloadcomplete).

What about this solution?

\\\
Private Sub WebBrowser1_DocumentCompleted( _
ByVal sender As Object, _
ByVal e As WebBrowserDocumentCompletedEventArgs _
) Handles WebBrowser1.DocumentCompleted
If Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
MsgBox("Document and frames loaded!")
End If
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 2 '06 #7
Herfried,

Did you try it, if it works than it is a great one?

:-)

Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
>You are number three asking this in this newsgroup. In my idea you cannot
do that with the new webbrowser (it is missing downloadcomplete).

What about this solution?

\\\
Private Sub WebBrowser1_DocumentCompleted( _
ByVal sender As Object, _
ByVal e As WebBrowserDocumentCompletedEventArgs _
) Handles WebBrowser1.DocumentCompleted
If Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
MsgBox("Document and frames loaded!")
End If
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 2 '06 #8
"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
Did you try it, if it works than it is a great one?
Yes, it worked for the framesets I tested on the Web, but I am not sure if
it will still work if one of the frames contains a media stream or similar
that is still loading after the actual /documents/ have been loaded.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 2 '06 #9
Document.Body.outerHTML gets reformatted / non-original
and INCOMPLETE html code. Looks like buggy : (


"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message news:eD**************@TK2MSFTNGP04.phx.gbl...
"nime" <ea****@planev.comschrieb:
>How can I grab html source of a frame?

I can retrive main frame by WebBrowser1.DocumentText
but I want to retrive inner (child) frame...

WebBrowser1.Document.Window.Frames(0).DocumentTex t like thing doesn't exist...

\\\
For Each Frame As HtmlWindow In Me.WebBrowser1.Document.Window.Frames
MsgBox(Frame.Document.All(1).OuterHtml)
Next Frame
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 2 '06 #10

"Document.Body.outerHTML gets reformatted / non-original
and INCOMPLETE html code. Looks like buggy : (
No it gives complete HTML code however not always everything on a page.

Cor
Jul 2 '06 #11
I mean webbrowser1.document.body.innerHTML has a bug here

innerHTML contains no form and I cannot fill the fields....

I've checked url, and compared the html code. Webbrowser1
reformats the tags and removes many lines. I call it as bug,
my form has been cropped : (

Then I tried Mozilla control, it has no problem, it parses everything
with no loss, but I couldn't use it, for example document.all.count
had an error...


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message news:%2****************@TK2MSFTNGP05.phx.gbl...
>
"Document.Body.outerHTML gets reformatted / non-original
>and INCOMPLETE html code. Looks like buggy : (
No it gives complete HTML code however not always everything on a page.

Cor

Jul 2 '06 #12
"nime" <ea****@planev.comschrieb:
>I mean webbrowser1.document.body.innerHTML has a bug here

innerHTML contains no form and I cannot fill the fields....

I've checked url, and compared the html code. Webbrowser1
reformats the tags and removes many lines. I call it as bug,
my form has been cropped : (
Maybe HTML Internet Explorer doesn't understand gets stripped from the
output and the result is simply the serialized part of the DOM tree.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 2 '06 #13
But the browser's itself displays the form in my app ???

I've got another problem with Mozilla control. I cannot fill the form fields which they exist.

AxMozillaBrowser1.Document.All.Item("login").Value = "xx"

line causes this error:

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Private Sub AxMozillaBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As
AxMOZILLACONTROLLib.DWebBrowserEvents2_DocumentCom pleteEvent) Handles AxMozillaBrowser1.DocumentComplete

If e.uRL.ToString = "http://www.domain.com/login.asp" Then
AxMozillaBrowser1.Document.All.Item("login").Value = "xx"
AxMozillaBrowser1.Document.All.Item("pass").Value = "xxx"

End If

End Sub

"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message news:uK**************@TK2MSFTNGP05.phx.gbl...
"nime" <ea****@planev.comschrieb:
>>I mean webbrowser1.document.body.innerHTML has a bug here

innerHTML contains no form and I cannot fill the fields....

I've checked url, and compared the html code. Webbrowser1
reformats the tags and removes many lines. I call it as bug,
my form has been cropped : (

Maybe HTML Internet Explorer doesn't understand gets stripped from the output and the result is simply the serialized part of the
DOM tree.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 2 '06 #14
1. Mozilla Activex control doesn't support all of
properties/methods/elements/etc.

2. IE WebBrowser control did not fire because I've blocked a few IP's
(via hosts file) and an ad related inner frame couldnt complete. So
WebBrowser1_DocumentComplete event did not fire. Now
I did unblock the IPs and event has been called again.

3. Now I have a new problem. Can you please read the topic:
WebBrowser: Programmaticaly click an image button ?

Thank you.

"nime" <ea****@planev.com>, haber iletisinde şunları
yazdı:u1**************@TK2MSFTNGP03.phx.gbl...
But the browser's itself displays the form in my app ???

I've got another problem with Mozilla control. I cannot fill the form
fields which they exist.

AxMozillaBrowser1.Document.All.Item("login").Value = "xx"

line causes this error:

A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Private Sub AxMozillaBrowser1_DocumentComplete(ByVal sender As Object,
ByVal e As AxMOZILLACONTROLLib.DWebBrowserEvents2_DocumentCom pleteEvent)
Handles AxMozillaBrowser1.DocumentComplete

If e.uRL.ToString = "http://www.domain.com/login.asp" Then
AxMozillaBrowser1.Document.All.Item("login").Value = "xx"
AxMozillaBrowser1.Document.All.Item("pass").Value = "xxx"

End If

End Sub

"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:uK**************@TK2MSFTNGP05.phx.gbl...
>"nime" <ea****@planev.comschrieb:
>>>I mean webbrowser1.document.body.innerHTML has a bug here

innerHTML contains no form and I cannot fill the fields....

I've checked url, and compared the html code. Webbrowser1
reformats the tags and removes many lines. I call it as bug,
my form has been cropped : (

Maybe HTML Internet Explorer doesn't understand gets stripped from the
output and the result is simply the serialized part of the DOM tree.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Jul 3 '06 #15
Herfried,

I can not reach you by mail. Can I use this in documentation (by instance
our website?)

Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:uq**************@TK2MSFTNGP03.phx.gbl...
"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
>Did you try it, if it works than it is a great one?

Yes, it worked for the framesets I tested on the Web, but I am not sure if
it will still work if one of the frames contains a media stream or similar
that is still loading after the actual /documents/ have been loaded.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 3 '06 #16
"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
I can not reach you by mail.
Sorry, unfortunately I was too busy to answer emails :-(.
Can I use this in documentation (by instance
our website?)
Yes, you can use it, but I suggest to test the solution extensively.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Jul 3 '06 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Florin | last post by:
Hi, How can get the javascript using a button Command1 ? I want to create the html on the fly. This one doesn't work: Private Sub Command1_Click() WebBrowser1.Navigate...
0
by: Raymond H. | last post by:
Hello, in my vb projet, I put a WebBrowser and when I view the contents of my hard disk with 'WebBrowser1.Navigate "C:\"' I view my directory in the right side only and in the left side it is'nt...
0
by: ata | last post by:
Hello ! I use WebBrowser class in .NetFramework 2.0 beta. When i work with english pages i don't have any problems, but if I trying to use it for russian page like www.ya.ru, I 've got a real...
2
by: myzm | last post by:
Hello there, I use webbrowser loading a web page and want to display the html file in a RichtextBox. I find out that the size of the DocumentText is far less than the actual size of the html...
0
by: webmaster | last post by:
Hi, i use WebBrowser1 component in my application. And i try to take web page's session ID in the WebBrowser1. Is that possible ? Thank you.
0
by: trint | last post by:
I want check for the document title, which is: <title> Golf Cart </title> I do this, trying to get it: webBrowser1.Navigate(new Uri(address)); label2.Text = webBrowser1.DocumentTitle;
2
by: Zytan | last post by:
I have a WebBroswer control, and I set the HTML it will display via DocumentText, which takes a a string. This shows the HTML code from the string in the control. But, sometimes, the WebBrowser...
0
by: micmit | last post by:
I wanted to avoid any HTML file creation , so initial HTML was formed as a string and assigned to DocumentText. After that the aim was to manipulate with html using DOM . It turned out...
7
by: - Electronic.HR - | last post by:
I have very strange and stupid problem with .NEt's webBrowser control... If I do this: ---------------------------------- private void btnGoogle_click(object sender, EventArgs e) { ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.