WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with MSIE
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Access Frame Object in InternetExplorer



Sample 1:

This example retrieve the source url of each frame
; Define url that contains frames

url = 'techsupt.winbatch.com'

; Frame info found techsupt.winbatch.com source html

;<frameset cols="33%,*" framespacing="4" frameborder="yes" border="1">
;   <frame name="left"  src="/webcgi/webbatch.exe?techsupt/nftechsupt.web"  scrolling="auto" marginwidth="2" marginheight="0">
;   <frame name="right" src="/rightside.html" scrolling="auto" marginwidth="2" marginheight="0">
;</frameset>

; Get a handle to the InternetExplorer Object
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp?frame=true

msie = ObjectCreate("InternetExplorer.Application")

; Set Visible Property to true. This tells the InternetExplorer object to be visible to the user.
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/properties/visible.asp

msie.visible = @TRUE

; Navigates to a resource identified by a URL or to the file identified by a full path.
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/methods/navigate.asp

msie.navigate(url)

; This code loops until the page is fully loaded
; Busy Property - Retrieves a Boolean value indicating whether the object is engaged in a navigation or downloading operation.
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/properties/busy.asp
;
; ReadyState Property - Retrieves the ready state of the object.
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/properties/readystate.asp

READYSTATE_COMPLETE = 4
While msie.busy || msie.readystate <> READYSTATE_COMPLETE
   TimeDelay(0.5)
EndWhile

; First we define the name of the frame. As you can see from the HTML frameset code posted above
; the frame names are frame name="left" and frame name="right"

FrameName = 'left'

; In order to access the Frames in the InternetExplorer Object you must first get the HTML Document Object
; this can be accomplshed using the Document Property
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/properties/document.asp

; The Document Property returns the Document Object.
; Documentation: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_document.asp

; The Document Object contains a collection of frames, that can be accessed using the Frames Collection.
; Documentation: http://msdn.microsoft.com/workshop/author/dhtml/reference/collections/frames.asp

; The Frames collection allows you to specify an integer or string that specifies the element or collection to retrieve.
; If this parameter is an integer, the method returns the element in the collection at the given position, where the first
; element has value 0, the second has 1, and so on. If this parameter is a string and there is more than one element with
; the name or id property equal to the string, the method returns a collection of matching elements.

; When you specify the element in the Frames Collection is returns a Window Object that represents an open window in the browser.
; Documentation: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_window.asp

; The Window Object contains Location Object that is used to retrieve information about the current URL.
; Documentation: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_location.asp

; The Location Object contains the Href Property that is used to retrieves the entire URL as a string
; Documentation: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_location.asp


href = msie.document.frames('%FrameName%').location.href
; or using an integer
; href = msie.document.frames(0).location.href
Message( StrCat( "HREF of FrameName", FrameName), href )

; Define the name of the other frame
FrameName = 'right'
href =  msie.document.frames('%FrameName%').location.href
; or using an integer
; href = msie.document.frames(1).location.href
Message( StrCat( "HREF of FrameName ", FrameName), href )

; InternetExplorer Object contains the Quit Method which is used to close the object
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/methods/quit.asp

msie.quit()

; Open Object clean up
; It is always a good idea to close any objects you opened by setting them equal to zero
msie = 0
Message("All","Done")
Exit


Sample 2:

This example retrieves the source html of each frame
; Define url that contains frames

url = 'techsupt.winbatch.com'

; Frame info found techsupt.winbatch.com source html

;<frameset cols="33%,*" framespacing="4" frameborder="yes" border="1">
;   <frame name="left"  src="/webcgi/webbatch.exe?techsupt/nftechsupt.web"  scrolling="auto" marginwidth="2" marginheight="0">
;   <frame name="right" src="/rightside.html" scrolling="auto" marginwidth="2" marginheight="0">
;</frameset>

; Get a handle to the InternetExplorer Object
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp?frame=true

msie = ObjectCreate("InternetExplorer.Application")

; Set Visible Property to true. This tells the InternetExplorer object to be visible to the user.
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/properties/visible.asp

msie.visible = @TRUE

; Navigates to a resource identified by a URL or to the file identified by a full path.
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/methods/navigate.asp

msie.navigate(url)

; This code loops until the page is fully loaded
; Busy Property - Retrieves a Boolean value indicating whether the object is engaged in a navigation or downloading operation.
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/properties/busy.asp
;
; ReadyState Property - Retrieves the ready state of the object.
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/properties/readystate.asp

READYSTATE_COMPLETE = 4
While msie.busy || msie.readystate <> READYSTATE_COMPLETE
   TimeDelay(0.5)
EndWhile

; First we define the name of the frame. As you can see from the HTML frameset code posted above
; the frame names are frame name="left" and frame name="right"

FrameName = 'left'

; In order to access the Frames in the InternetExplorer Object you must first get the HTML Document Object
; this can be accomplshed using the Document Property
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/properties/document.asp

; The Document Property returns the Document Object.
; Documentation: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_document.asp

; The Document Object contains a collection of frames, that can be accessed using the Frames Collection.
; Documentation: http://msdn.microsoft.com/workshop/author/dhtml/reference/collections/frames.asp

; The Frames collection allows you to specify an integer or string that specifies the element or collection to retrieve.
; If this parameter is an integer, the method returns the element in the collection at the given position, where the first
; element has value 0, the second has 1, and so on. If this parameter is a string and there is more than one element with
; the name or id property equal to the string, the method returns a collection of matching elements.

; When you specify the element in the Frames Collection is returns a Window Object that represents an open window in the browser.
; Documentation: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_window.asp

; The Window Object contains Document Object that represents the HTML document in a given browser window. .
; Documentation: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_document.asp

; The Document Object contains the Body Object
; Documentation: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_location.asp

;The Body Object contains the InnerHTML Property that retrieves the HTML between the start and end tags of the object.


InnerHTML = msie.document.frames('%FrameName%').document.body.InnerHTML
; or using an integer
; InnerHTML = msie.document.frames(0).document.body.InnerHTML
Message( StrCat( "InnerHTML of FrameName", FrameName), InnerHTML )

; Define the name of the other frame
FrameName = 'right'
InnerHTML = msie.document.frames('%FrameName%').document.body.InnerHTML
; or using an integer
; InnerHTML = msie.document.frames(1).document.body.InnerHTML
Message( StrCat( "InnerHTML of FrameName", FrameName), InnerHTML )

; InternetExplorer Object contains the Quit Method which is used to close the object
; Documentation: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/methods/quit.asp

msie.quit()

; Open Object clean up
; It is always a good idea to close any objects you opened by setting them equal to zero
msie = 0
Message("All","Done")
Exit

Article ID:   W17176
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38