How would I view the source of the web page using the msft web browser control?
Printable View
How would I view the source of the web page using the msft web browser control?
Welcome to the Forums.
I take it that your using 2005? In vb6 we had the web browser control and when we wanted to see the source we would use the Webbrowser1.Document.innertext etc.
Yes, innertext returns just the basic text with no html coding, InnerHTML returns inner text with HTML tags inside of the Body of the document, OuterHTML returns all HTML information, including header info...
Your right gig :thumb: I cant wait to get the RTM version of 2005 so I can install it on my production system. :D
I'm still using 2002... have a copy of 2003 on its way in the mail, trading some dvd's and a little cash for a friend's copy... finally catch up a little.. im still way behind... And yet there is the 2005 around the corner....
You should order the Beat 2 version of 2005 as you only have a few weeks left before the ready to market version comes out. After that the free betas will no longer be available.
Going to the site now... free shipping isnt available anymore, but I think I can handle the 6 bucks to ship :)
If your in the USA its should be about that. I paid $6 if I remember correctly. Dont pay for the fast shipping. I used regular shipping and it can in 2 ro 3 days not the 4 weeks that they said.
Get the Visual Studio Team System. Its got it all I think.
Its on its way, Rob :)
P.S. I keep tryin to rate ya.. but its still tellin me I need to "Spread More Reputation Around" before giving it to you again hehehe
nope im using .net 2003. would it still be the same as the vb6 code?
It should be since the web browser is a COM control in 2002 and 2003. Just try like we suggested.
VB Code:
Webbrowser1.DocumentElement.InnerHTML
The method of innertext, innerhtml, outerhtml, is all just methods of the html object. I'm assuming you are displaying the HTML object using this webbrowser control, so just run the objects method...
VB Code:
'Assuming an html object called "MyHTMLObj" Dim MyString as string MyString = MyHTMLObj.documentElement.innerText.ToString 'or MyString = MyHTMLObj.documentElement.innerHTML.ToString 'or MyString = MyHTMLObj.documentElement.outerHTML.ToString 'etc etc etc
Ok, i had to add a webbrowser control to a test project to doublecheck. I dont get the documentelement property?
VB Code:
AxWebBrowser1.Document.ToString()
I've never used the web browser control, but isn't it loading some form of an HTML object? I assumed it was, so you would refer to the webrowser html object that it is loading... but I could be wrong, won't be the first time :)
It gives me an error that "documentElement is not a member of..."
Here's a little bit of text I found on another page about the AXWebBrowser...
...
3. Make sure the document is loaded. (The DocumentCompleteEvent shows this.)
4. Get the AxWebBrowser.Document object and cast it to mshtml.IHTMLDocument2.
5. Set IHTMLDocument2.body.innerHTML property to the HTML string.
....
Also remember to add "Imports mshtml" at the top..
I suppose youalso need a reference set to get the "mshtml"? Makes a bit of sense those. :thumb:
How about this... It doesnt show in the members list but it doesnt give an error either. :D
VB Code:
AxWebBrowser1.Document.innerHTML.ToString()
lol yep... forgot about adding the MSHTML reference... :)