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.

Dealing with iFrames


Question:

How do I deal with inline frames in a page with dimensions and no name attribute? I want to be able to access the source document. Here's sample below. Suggestion anyone? < iframe width="100%" height=600 frameborder=0 src='source.html' >< /iframe >

Answer:

IFrameCollection = browserdoc.GetElementsByTagName("IFRAME")

Message("Debug", IFrameCollection.length)

User Reply:

The iFrame element defines an inline frame for the inclusion of external objects including other HTML documents. It provides a subset of the functionality of OBJECT; the only advantage to it is that an inline frame can act as a target for other links. So in a sense it is a frame. I was thinking that I would have to treat it the same way winbatch handles frames by pointing to the item I need. I have not seen anything here about iFrames.

I think that you misunderstood me. I meant that I want to access information in the source.html that opens up within this inline frame.

Answer:

I'm not sure you can. I seem to remember that IFrames had some sort of special features, so that they can't be manipulated the same as web pages.

DebugTrace(@ON,DirScript():'Trace-IFrames.txt')

#DefineSubRoutine startMSIE()
DebugTrace(22,'')
   Browser = ObjectCreate("InternetExplorer.Application")
   Browser.addressbar = @TRUE
   Browser.statusbar = @TRUE
   Browser.menubar = @TRUE
   Browser.toolbar = @TRUE
   browser.visible = @TRUE
   browser.navigate(url)
   ;wait until page loads...
   WaitForPageLoad()

   ;setup the document object...
   browserDoc = Browser.Document
   Return(browserDoc)
#EndSubRoutine

#DefineSubRoutine WaitForPageLoad()  ; assume Browser
DebugTrace(22,'')
   While browser.busy || browser.readystate == 1
      TimeDelay(0.5)
   EndWhile
   Return
#EndSubRoutine




URL = "http://www.htmlcodetutorial.com/frames/_IFRAME.html"
browserDoc = startMSIE()
WaitForPageLoad()


iFrameCollection = Browser.Document.GetElementsByTagName("IFRAME")
iFrameCount = IFrameCollection.length

For x = 0 To iFrameCount-1
   Frame_Obj = IFrameCollection.item(x)
   last = 0
   ErrorMode(@OFF)
      daName = Frame_Obj.name
      last = LastError()
      If last Then daName = ""
   ErrorMode(@CANCEL)
   last = 0
   ErrorMode(@OFF)
      daId = Frame_Obj.id
      last = LastError()
      If last Then daId = ""
   ErrorMode(@CANCEL)
   ErrorMode(@OFF)
      daSrc = Frame_Obj.Src
      last = LastError()
      If last Then daSrc = ""
   ErrorMode(@CANCEL)
   If VarType(daName) == 512 && daName == "" Then daName = "" ; these two statements are needed to
   If VarType(daId) == 512 && daId == "" Then daId = ""         ; determine if the result is empty
   If VarType(daSrc) == 512 && daSrc == "" Then daSrc = ""         ; determine if the result is empty
   Pause("Frame ":x,"Name = ":daName:@CRLF:"ID = ":daId:@CRLF:'SOURCE = ':daSrc)
Next


browser = 0
Message("All","Done")
Exit

Article ID:   W16631
File Created: 2011:06:21:14:51:28
Last Updated: 2011:06:21:14:51:28