SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Resource

Scripting Defensively

Categories...
Client User Group
Site Design, Write Once!
Language
JavaScript
Product
IE4
Task
Performance Tuning
Technology
ECMA-262

Sponsored Links
Developer's Paradise : Inside Technique :
Scripting Defensively
Submission by SiteExperts Staff

Go to the resource:
Scripting Defensively

Add to Assistant

Short Description
You think your scripts are robust? Learn defensive scripting techniques.

Long Description
You think your scripts are robust. Learn a couple techniques for improving script performance and for preventing pesky script errors.

Author
Scott Isaacs
Submission URL
http://www.SiteExperts.com/tips/functions/ts06/page1.asp
Submission Date
Mar 25,1998
 

Discussion and Rate this Resource
Overall Rating: 4.3

ChrisNightingale on Jun 1, 2001 at 5:46:12 AMRating: 4
Useful article about how to prevent errors on start up which has been a real stumbling block for our pages.  I am already using the "flag" version which is set on the "onLoad" event although I have found that if the "flag" is declared in a separate file (e.g. a ".js" file) then it can often be undefined during start-up (I assume, due to the separate file not yet being fully loaded).  Seems to be ok if located in the a <script> block in the <head> section of the main page.
stevehorwitz on Sep 1, 1999 at 1:12:24 PMRating: 4

Useful info.  Even using your suggestion of onload(), I was unable to properly load an image, however.  I adopted code that looks like:

MyImage = new Image();
MyImage.src = ImgName;

ImgHeight = MyImage.height;
ImgWidth = MyImage.width;

intCounter = 0
while(ImgHeight == 0 && ++intCounter < 10000)
{
MyImage.src = ImgName;
ImgHeight = MyImage.height;
ImgWidth = MyImage.width;
}

This appears to work in my situation.

BTW, "eg." is spelled "e.g." and is always followed by a comma.

Good site, please keep adding articles!

Steve Horwitz

 

 

graemesmith on Apr 10, 1999 at 2:54:16 AMRating: 5
Now I understand!
sherdim on Apr 4, 1999 at 11:07:45 PMRating: 3


To rate and comment on a resource, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password

Copyright © 1997-2008 InsideDHTML.com, LLC. All rights reserved.