Get Head part from web browser control 
Author Message
 Get Head part from web browser control

Hello all,

I want to get Head part from web browser control, but it doesnt seems to
work.

WB1.Document.head.innerHTML

how to get all html between <head></head> section.

thanks for any help.
--
abhishek



Thu, 02 Feb 2012 05:59:34 GMT  
 Get Head part from web browser control
  This shouldn't work, because HEAD doesn't
have an outerhtml property, but it seems
to work nevertheless on all tags in a document. :)

  For i = 0 to document.all.length - 1
     If document.all(i).tagname = "HEAD" Then
      s = document.all(i).outerhtml
      Exit For
    End If
 Next

To get the whole doc.:

   For i = 0 to document.all.length - 1
      s = s & document.all(i).outerhtml
   Next

s will be the entire page, from <HTML> to </HTML>

   You might want to double-check to make sure
you get it all. Also note, a WB or IE will corrupt
your code when returned this way. For instance, I
just tested on an HTA I'm writing and got this
back after the HTML tag:
<?XML:NAMESPACE PREFIX = HTA />
  I've never used an XML tag in my life! And I never use
xhtml closing /> marks.
  I also often see things like <B> being replaced by
<STRONG>, etc. It's as though IE/WB had converted
the page into a DOM and can only get it back by
reconstituting the HTML from that DOM. That might be
OK if you're not going to redisplay the page, but if you
want to edit and re-use, especially in another browser,
then watch out for corrupted code.

Quote:
> I want to get Head part from web browser control, but it doesnt seems to
> work.

> WB1.Document.head.innerHTML

> how to get all html between <head></head> section.

> thanks for any help.
> --
> abhishek



Thu, 02 Feb 2012 08:27:06 GMT  
 Get Head part from web browser control


Quote:
> Hello all,

> I want to get Head part from web browser control, but it doesnt seems to
> work.

> WB1.Document.head.innerHTML

> how to get all html between <head></head> section.

Yeah, that DOM has always been hard to understand and use.
I was able to get it using the following function:

Function HeadHTML() As String
Dim all, itm
  Set all = WebBrowser1.Document.all
  For Each itm In all
    If TypeName(itm) = "HTMLHeadElement" Then
      HeadHTML = itm.innerHTML
      Exit For
    End If
  Next
End Function

See if that helps...
LFS



Thu, 02 Feb 2012 08:38:01 GMT  
 Get Head part from web browser control
thanks a lot! :)


Fri, 03 Feb 2012 02:49:32 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. getting a complete load of wed page in web browser control

2. getting a complete load of wed page in web browser control

3. Web browser control, .Document object browser/viewer?

4. Web Browser: Opening link in new Web Browser window

5. How to make my web browser as a default web browser

6. Printing a Web Page in Web Browser Control

7. Detecting bad web site in web browser control

8. Question on getting my program using Web browser to access

9. Getting an address from a web browser

10. Getting The Web Browser Error?

11. Automation Error from Web Browser Control in VB5 Control

12. How to control scroll bars in Web Browser Control

 

 
Powered by phpBB® Forum Software