雨中的高速公路 - bluetent的个人主页

我的电脑,最近新歌,欧美音乐,酷讯,电脑技术

Google个性化页面中实例化XMLHTTP对象的方法

7月 22nd, 2005 · No Comments

function x()
{
	var a=null;
	try
	{
		a=new ActiveXObject(“Msxml2.XMLHTTP”);
	}
	catch(c)
	{
		try
		{
			a=new ActiveXObject(“Microsoft.XMLHTTP”);
		}
		catch(b)
		{
			a=null;
		}
	}
	if(!a&&typeof XMLHttpRequest!=”undefined”)
	{
		a=new XMLHttpRequest();
	}
	return a;
}

  这个实例化方法至少支持IE、Firefox、Opera和Safari,它的一大特色是用了try…catch…,而不是经常用的if…else…,这种方式是比较稳妥和有效的。

历史上的今天

Tags: 原创文档

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment