JavaScript != Java. Moving to c.l.js
Dorothy Mantooth wrote:
My company is switching from using a vendor DNS server to our own as
well as creating a new network. We want to verify whether or not our
customers can "reach" our new network so we have placed some
JavaScript on the logon page of one of our applications to check for
the existence of an image on the new network. We have had over 20,000
successes and about 300 failures. I want to know if the failures
could be do to the following scripting code or if we should continue
to look at the DNS, ACL's, etc. I want to rule out the script. The
failures are falling into the isBad funciton and we are logging.
Expand|Select|Wrap|Line Numbers
- function testImage(URL)
- var tester=new Image();
- tester.onload=isGood;
- tester.onerror=isBad;
- tester.src=URL;
- }
- function isGood() {
- if( debug ) {
- alert('Image exists!');
- //Log success (around 20,000)
- }
- }
- function isBad() {
- if( debug ) {
- alert('Image does no exist!');
- //Log failure (around 300)
- }
- }
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth