javascript 跨域名 精简

javascript 跨域名 精简

function hotsearch(index)
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
//sortname = encodeURI(sortname);
}
else
{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
//sortname = encodeURI(sortname);
}
//q = encodeURI(type);
gScriptObj = document.createElement("script");
gScriptObj.setAttribute(
"type", "text/javascript");
gScriptObj.setAttribute(
"charset", "utf-8");
//if(index ==1)
//{
gScriptObj.setAttribute("src", index); //index为ajax需要访问的url地址
headObj
= document.getElementsByTagName("head").item(0);
headObj.appendChild(gScriptObj);
 headObj = document.getElementsByTagName("head").item(0);                                                                                                                 
        headObj.appendChild(gScriptObj);  

}


  

posted @ 2011-07-19 14:32  wangkangluo1  阅读(211)  评论(0编辑  收藏  举报