[求助]ajax兼容问题
<P>ajax兼容问题,大家帮我看看,我的在ff和opera下不惯用啊,急死人了,是不是js不规范,大家帮我修正下,谢谢.</P><P><BR>[code]<!--<BR>var xmlHttp;<BR>function GetNowTime(){<BR> var date = new Date(); //ÈÕÆÚ¶ÔÏó <BR> var now = ""; <BR> now = date.getFullYear()+"y";<BR> now = now + (date.getMonth()+1)+"m";<BR> now = now + date.getDate()+"d"; <BR> now = now + date.getHours()+"h"; <BR> now = now + date.getMinutes()+"m"; <BR> now = now + date.getSeconds()+"s";<BR> return now;<BR>}<BR>function CleanLoading(){<BR> document.getElementById('loading').innerHTML = "";<BR>}<BR>function createXMLHttpRequest(){<BR> if (typeof XMLHttpRequest == "undefined"){<BR> var xmlHttpVersions = [ "MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];<BR> for(var i = 0;i < xmlHttpVersions.Length;i++){<BR> try{<BR> return new ActiveXObject(xmlHttpVersions[i]);<BR> }<BR> catch(oError){<BR> //there is nothing to do with<BR> }<BR> }<BR> throw new error("there whould be no error at all!");<BR> }<BR> else if (window.XMLHttpRequest){<BR> return new XMLHttpRequest();<BR> }<BR>}<BR> <BR> if (ajax == null && typeof XMLHttpRequest != 'undefined')<BR> {<BR> ajax = new XMLHttpRequest();<BR> }<BR> <BR> return ajax;<BR>}<BR>function starRequest(object,VerID){<BR> var url;<BR> switch(object){<BR> case 1: { //Â¥ÅÌÐÅÏ¢,ÏîÄ¿¸Å¿ö<BR> url = "/ajax/gaikuang.php?VerID="+VerID+"&time="+GetNowTime();//¼ÓÈëʱ¼ä´Á,±ÜÃâä¯ÀÀÆ÷»º´æ<BR> break;<BR> }<BR> case 2: { //Â¥ÅÌÐÅÏ¢,ÏîÄ¿¸Å¿ö<BR> url = "/ajax/gaikuang.php?VerID="+VerID+"&time="+GetNowTime();<BR> break;<BR> }<BR> }<BR> xmlHttp = createXMLHttpRequest();<BR> xmlHttp.onreadystatechange = handleStateChange;<BR> xmlHttp.open("get",url,true);<BR> xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");<BR> xmlHttp.send(null);<BR>}<BR>function handleStateChange(){<BR> document.getElementById('loading').innerHTML = "<img src='/images/loading3.gif'/>Êý¾Ý¼ÓÔØÖÐ...";<BR> if(xmlHttp.readyState == 4){<BR> if(xmlHttp.status == 200){<BR> document.getElementById('main').innerHTML = xmlHttp.responseText;<BR> }<BR> }<BR> setTimeout("CleanLoading()",500);<BR>}<BR>-->[/code]</P>
页:
[1]
