I am trying to automate the daily morning system checks. Part of the
items to check is a bunch of URL's. I have a script that opens them
all in a new window for manual verification. It seems possible but I
can't figure out how to determine the status of the recently navigated
url. Is there anyway way to use .NavigateError or some other method to
determine if a 404 error type is the result of the navigate function?

Re: Determinine IE.Navigate2 Status by \

\
Mon Jan 23 11:28:23 CST 2006

> I am trying to automate the daily morning system checks. Part of the
> items to check is a bunch of URL's. I have a script that opens them
> all in a new window for manual verification. It seems possible but I
> can't figure out how to determine the status of the recently navigated
> url. Is there anyway way to use .NavigateError or some other method to
> determine if a 404 error type is the result of the navigate function?

Speaking from abject ignorance, I doubt it. IE doesn't fail. It loads a page at
the specified URL. It just isn't the page you want. The only way I can think of
would be to read the page contents and determine what is on it. Something like
this:

if instr(IE.document.body.innerText,"HTTP 40") then msgbox "Navigation error!"

This is risky because not all error pages are the same and some server
administrators like to get "cute" with their error messages. If all the morning
URL's are on a constant and controlled system, like a LAN, you should be OK.
--
Crash





Re: Determinine IE.Navigate2 Status by jkavanagh58

jkavanagh58
Mon Jan 23 11:41:49 CST 2006

I thought about a text stream read but wasn't sure how that would work
or read the window title that should indicate "Page Not Found". Thanks.


Re: Determinine IE.Navigate2 Status by jkavanagh58

jkavanagh58
Mon Jan 23 11:52:03 CST 2006

How do you invoke IE.document in your example? For example I have
CreateObject("InternetExplorer.Application") and as best I can tell
.Document is at the same level as Application, do I need to create a
second object for InternetExplorer.Document?


Re: Determinine IE.Navigate2 Status by \

\
Mon Jan 23 12:27:05 CST 2006

> How do you invoke IE.document in your example? For example I have
> CreateObject("InternetExplorer.Application") and as best I can tell
> .Document is at the same level as Application, do I need to create a
> second object for InternetExplorer.Document?

How are you checking the URL's? Don't you have to "navigate" to them?

Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://hal9000/nada.htm"
do until IE.readyState = 4 : wscript.sleep 10 : loop
if instr(IE.document.body.innerText,"HTTP 40") then msgbox "Navigation error!"

Note that this works with default error pages on an IIS server, but didn't work
on an Apache server because the error text didn't contain the string I search
for. It will have to be tailored for your situation.
--
Crash



Re: Determinine IE.Navigate2 Status by jkavanagh58

jkavanagh58
Mon Jan 23 12:48:07 CST 2006

Ah ha, found my own typo..... thanks a million.


Re: Determinine IE.Navigate2 Status by Alexander

Alexander
Tue Jan 24 03:40:27 CST 2006

jkavanagh58 schrieb:
> I am trying to automate the daily morning system checks. Part of the
> items to check is a bunch of URL's. I have a script that opens them
> all in a new window for manual verification. It seems possible but I
> can't figure out how to determine the status of the recently navigated
> url. Is there anyway way to use .NavigateError or some other method to
> determine if a 404 error type is the result of the navigate function?

NavigateError is an event that occurs on HTTP-errors, like 404.
It also tells you the errorcode, anything but 200 is error.


set ie = wscript.createobject("internetexplorer.application", "ie_")
ie.Navigate "http://www.cnn.com/iunknown.nodispatch.aspx"
ie.Visible = true


While 1 : WSH.Sleep 1000 : Wend


Sub ie_NavigateError(pDisp, URL, TargetFrameName, _
StatusCode, ByRef Cancel)

WSH.Echo "NavigateError, url: ", URL, vbcr & _
"StatusCode:", StatusCode

End Sub

Sub ie_Quit
WSH.Quit
End Sub

Mfg,
Alex

Re: Determinine IE.Navigate2 Status by \

\
Tue Jan 24 07:11:37 CST 2006

Neat! I didn't know server errors were detectable. Thanks.
--
Crash