WebBrowser control

I'm creating an internet app with a browser control.
I'd like to know how to get the html source (like the view source menu in Internet Explorer) or to select all the content of a web page and copy it to the clipboard.
Thank you.
Minette
minetteAsked:
Who is Participating?
 
AzraSoundConnect With a Mentor Commented:
solution i gave will only work for a page with no frames, here is the complete answer:

to get the number of frames on the page use this

MsgBox WebBrowser1.Document.frames.length


to get any source from any frame:

Text1.Text = WebBrowser1.Document.frames(x).Document.body.innerhtml

where x is the frame number/index of the frame you want to view




0
 
AzraSoundCommented:
use the internet transfer control
from projects -> components choose microsoft internet transfer control
to get the source use this code

Dim source As String
source = Inet1.OpenUrl("http://www.somesite.com")
0
 
AzraSoundCommented:
for the clipboard you can use it this way:

Clipboard.SetText Inet1.OpenURL("http://www.experts-exchange.com")

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
mcriderCommented:
There is a complete webbrowser example on your Visual Basic CD... Load the project in: \TOOLS\UNSUPPRT\HTTPEXPL

I think this is everything you need...


Cheers!®©
0
 
minetteAuthor Commented:
mcrider,
The example on the CD doesn't show what i need :-)

AzraSound,
Your solution is quite good but when trying to get the source code of a webpage, only about half was displayed.
Do you have a solution for that or maybe i've done something wrong ?

Any idea about "Select all" the content of a web page and Copy it (that way, i wouldn't have html tags).

0
 
mcriderCommented:
When you run the example application I told you about and load a URL using "File->Open URL" the source of the document appears in the upper-righthand window... I thought you wanted the source of the HTML document???


Cheers!®©
0
 
AzraSoundCommented:
which sites are you not getting all the source from?
0
 
AzraSoundCommented:
hello try this method instead:

Text1.Text = WebBrowser1.Document.body.innerhtml
0
 
minetteAuthor Commented:
Answer accepted
0
 
minetteAuthor Commented:
Sorry for the late answer !
It works fine.
Thanks.
0
 
AzraSoundCommented:
glad i could help  =)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.