Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: navigate IE bad URL error event handler ObjectEventAdd InternetExplorer.Application
; Event handler subroutine. #DefineSubRoutine NavigateError(pDisp, URL, Frame, StatusCode, CANCEL) ; Indicate that the URL is not valid bValidUrl = @FALSE ; Debug message. Message("Error Invalid URL", URL) ; Cancel navigations by setting the last parameter. ; It prevents IE from starting a new instance ; with an error page. ; (This only works if an otherwise valid server ; does not provide an error page.) CANCEL = @TRUE Return 0 #EndSubRoutine ; Set the url flag optimistically. bValidUrl = @TRUE ; Create an IE object objBrowser = ObjectCreate("InternetExplorer.Application") objBrowser.addressbar = @TRUE objBrowser.statusbar = @TRUE objBrowser.menubar = @TRUE objBrowser.toolbar = @TRUE objBrowser.visible = @TRUE ObjectEventAdd( objBrowser, "NavigateError", "NavigateError" ) URL = "http://www.Notavalidurl.bad" ; Invalid url ;URL = "http://www.winbatch.com" ; Valid url objBrowser.navigate(Url) ; Wait only while URL is valid or still loading While objBrowser.busy || objBrowser.readystate <> 4 ; Kills IE on bad URL. If !bValidUrl objBrowser.Quit objBrowser = 0 Break ; Abort loop EndIf TimeDelay(0.5) EndWhile
Article ID: W17453
File Created: 2008:04:10:15:10:44
Last Updated: 2008:04:10:15:10:44