My comments on ...

... everything bothering me

The better way of Capability Detection

, ,

In response to Crisp's post about "capability detection" (and his comment system, that ate most of my messages...):

The goal was to optimize the code provided so the "if" statements were not part of the function anymore.

The code wrapped around the "finally" construct might stand alone, and I'm sure the code could be otherwise shortened, but I think this should work all in all...

if (!window.XMLHttpRequest)
{
     var temp;
     var types = [
         'MSXML2.XMLHTTP.6.0',
         'MSXML2.XMLHTTP.3.0'
     ];
 
     for (var i = 0; i < types.length; i++)
     {
         try
         {
             temp = function(){return new ActiveXObject(types[i])};
             void(temp());
         }
         catch(e) {temp = null;}
         finally {if(temp) break;}
     }
     window.XMLHttpRequest = temp || function(){return undefined};
}

The better way of Capability Detection, Part 2

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies

February 2012
M T W T F S S
January 2012March 2012
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29