getting the objects

Posted: April 12, 2007 in next to nothing

since i not-so-recently have been making web 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;
}



Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s