VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



You too can access all the properties/methods/events of the webbrowser + html object w/o 1 control

by Evan Toder (30 Submissions)
Category: Coding Standards
Compatability: VB Script
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (3 Votes)


How you can access all the properties, methods, and
events of the html object libray/webbrowser control
with using any webbrowser or winsock or inet control.
Most people believe that in order to use these objects
you have to load some sort of browser object
into memory..which has always been problem for me
since i know that IE has a lot of security holes.
the secret basically lies in one method of the
HTMLobject library. it is the ".CreateDocumentFromURl"
method
It goes something like this

Rate You too can access all the properties/methods/events of the webbrowser + html object w/o 1 control



How you can access all the properties, methods, and

events of the html object libray/webbrowser control

with using any webbrowser or winsock or inet control.



Most people believe that in order to use these objects

you have to load some sort of browser object

into memory..which has always been problem for me

since i know that IE has a lot of security holes.



the secret basically lies in one method of the 

HTMLobject library. it is the ".CreateDocumentFromURl"

method

It goes something like this





 '

dim start_time as long

 '

 '

 'set a reference to the 

 'Microsoft HTML object library

 '

 '========================================



sub GetDocObject(byval sUrl as string )

  dim objHTML as new htmlDocument

  dim objDoc  as htmlDocument



   set objDoc=objHtml.CreateObjectFromUrl(sUrl)



 'we now have to wait for the document to be set

 'you probably want some sort of time out

 'value in case of unforseen network problems

 'otherwise you caught in the dreaded hanging

 'loop



   start_time = getTickCount  'API call



   while objDoc.readystate <> "complete"

       '5 second timeout value

      if (gettickcount - start_time) > 5000 then

           exit sub

      end if

      doevents

   wend



    'reaching this point in code means

    'the document object has been set

    'and you can handle it any way you

    'wish accessing its links, tables..whatever

    'for example



     dim lcnt as long

     dim upper as long

     dim oLink as htmlAnchorElement



     upper = objDoc.GetElementsByTagName("A").length -1



     if upper > 0 then



        for lcnt = 0 to upper-1

            set oLink = objDoc.GetElementsBytagName("A")(lcnt)

            list1.additem oLink.href 

        next lcnty

     end if





end sub

  

Download this snippet    Add to My Saved Code

You too can access all the properties/methods/events of the webbrowser + html object w/o 1 control Comments

No comments have been posted about You too can access all the properties/methods/events of the webbrowser + html object w/o 1 control. Why not be the first to post a comment about You too can access all the properties/methods/events of the webbrowser + html object w/o 1 control.

Post your comment

Subject:
Message:
0/1000 characters