[thelist] Make JavaScript Fail - Safe

Hassan Schroeder hassan at webtuitive.com
Mon Jan 19 01:10:56 CST 2004


Sam Carter wrote:

 > I'm guessing it's the getElementById.  Is there a way to make this
 > script fail safe?

Something like this should help :-)

function resizeBox()
{
   if ( document.getElementById )
   {
     sObj = document.getElementById("container")
     if ( sObj )
     {
       if(document.body.clientWidth)
       {
         sObj.style.width = (document.body.clientWidth > 
1024)?"900px":"100%";
       }
     }
   }
}

HTH,
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the thelist mailing list