[thelist] Make JavaScript Fail - Safe

Sam Carter sam at nativeintelligence.com
Mon Jan 19 00:54:58 CST 2004


<!-- hide script from old browsers
function resizeBox(){
 sObj = document.getElementById("container")
 if ( sObj ) {
  if(document.body.clientWidth) (document.body.clientWidth>900) ?
sObj.style.width = "900px" :  sObj.style.width = "100%" 
 }
}
  
  window.onload = resizeBox;
  window.onresize = resizeBox; 
// end hiding script from old browsers -->
 
This script pulls an error in some older browsers (IE 4.0 being one of them)
resulting in a large pop-up error window for my users.
 
I'm guessing it's the getElementById.  Is there a way to make this script
fail safe?
 
Sam


More information about the thelist mailing list