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);  

}


  

相关文章:

  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-02
  • 2022-12-23
  • 2021-09-23
  • 2021-10-29
  • 2021-06-17
相关资源
相似解决方案