getting the objects

since i not-so-recently have been working on web pages/UIs that are only used within the company, i almost always don’t care whether it works for IE or not. it’s bad practice, yes. but then i could just tell the marketing guys to “use damned Firefox for heaven’s sake!

then again you can’t tell the whole world to use Firefox. actually you could but what about that IE 7 and its tabs? or what’s Firefox? i’ll bet grandma will ask you that.. .

well here’s a useful javascript function that you might want to use in AJAX. it will return the necessary object needed for it to work on major browsers such as Firefox and IE. it should work with Safari too. i haven’t tried it out with Opera.

    function getXMLHttpRequestObject()
    {

        if (window.XMLHttpRequest){
            return new XMLHttpRequest();
        }        
        else if (window.ActiveXObject){
            return new ActiveXObject("Microsoft.XMLHTTP");
        }    
        
        return null;
    }


Similar Posts: