Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: frame frames MSIE IE Internet Explorer webpage
; This will inventory a webpage and find all FRAMES and any ; subframes underneath them, record their position and name ; and show their relationship to other frames. ; Jay Alverson Winbatch 2008C + MSHTML + MSXML 3.0 #DefineFunction ParseXML(xml) rdr = ObjectOpen("Msxml2.SAXXMLReader.3.0") wrt = ObjectOpen("Msxml2.MXXMLWriter.3.0") wrt.byteOrderMark = @FALSE wrt.omitXMLDeclaration = @TRUE wrt.indent = @TRUE ;'set the writer to the content handler rdr.contentHandler = wrt rdr.dtdHandler = wrt rdr.PutProperty("http://xml.org/sax/properties/lexical-handler", wrt) rdr.PutProperty("http://xml.org/sax/properties/declaration-handler", wrt) rdr.Parse(xml) newxml = wrt.output ObjectClose(wrt) ObjectClose(rdr) Return(newxml) #EndFunction #DefineFunction FindFramesXML(obj, xmldoc, parentNode) ; look for frames under this OBJECT reference... If obj.frames.length ; loop thru the collection... For i = 0 To obj.frames.length-1 Frame_Obj = obj.frames(i) ; Message("Debug", Frame_Obj.className) ; see if it has a name and id... ; ; unfortunately MSHTML won't tell me which CLASS of ; node I have, like: Class IHTMLWindow2 Member of MSHTML ; Frame_Obj.className gets 1258 error... on the "t-online.de" site ; and NO ERRORS on stan's site, but a blank string. ; so we have to guess and the easiest way is to ignore ; errors when looking up the .attributes... ; 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) 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 ; ; to avoid a type mismatch during .setAttribute() ; create a Frame element for the results... NewFrameNode = xmlDoc.createElement("Frame") ; record it's position & name... NewFrameNode.setAttribute("Position", i) NewFrameNode.setAttribute("Name", daName) NewFrameNode.setAttribute("Id", daId) ; place it underneath it's parent... parentNode.appendChild(NewFrameNode) ; see if this node has any subframes and start over... FindFramesXML(Frame_Obj, xmlDoc, NewFrameNode) Next EndIf NewFrameNode = 0 Return #EndFunction #DefineFunction startMSIE(url) msie = ObjectCreate("InternetExplorer.Application") msie.addressbar = @FALSE msie.statusbar = @FALSE msie.menubar = @FALSE msie.toolbar = @FALSE msie.visible = @TRUE msie.navigate(url) WaitForMSIE(msie) Return(msie) #EndFunction #DefineFunction WaitForMSIE(msie) While msie.busy || msie.readystate <> 4 TimeDelay(0.5) EndWhile Return #EndFunction #DefineSubRoutine CloseMSIE() Exit Return #EndSubRoutine ; set URL for website... ; url = "t-online.de" br = startMSIE(url) ; set up a close event ; dbr = br ObjectEventAdd(dbr, "onquit", "CloseMSIE") ; setup the Top/Window object reference... ; Top = br.document.parentWindow ; setup the XML document to record all the frames & info... ; xmlDoc = ObjectOpen("Msxml2.DOMDocument.3.0") xmlDoc.async = @FALSE xmlDoc.setProperty("SelectionLanguage","XPath") xmlDoc.loadXML("<FrameList/>") ; Inventory the page and all its frames/subframes... ; FindFramesXML(Top, xmlDoc, xmlDoc.documentElement) TotalFrames = xmlDoc.selectNodes("//Frame").length ; show the results... ; Message("Found %TotalFrames% Frames", ParseXML(xmlDoc.xml)) ClipPut(ParseXML(xmlDoc.xml)) ; clean up and exit... ; xmlDoc = 0 Top = 0 br.quit br = 0 Exit
Article ID: W18131
Filename: Inventory Frames.txt
File Created: 2008:10:06:08:31:04
Last Updated: 2008:10:06:08:31:04