防止JS路径跳转地址栏带参数

来源:互联网 发布:文件夹整理软件 编辑:程序博客网 时间:2024/04/28 01:26

js代码如下

function createXMLHttpRequest(){    if(window.XMLHttpRequest){        XMLHttpR = new XMLHttpRequest();    }else if(window.ActiveXObject){        try{            XMLHttpR = new ActiveXObject("Msxml2.XMLHTTP");        }catch(e){            try{                XMLHttpR = new ActiveXObject("Microsoft.XMLHTTP");            }catch(e){            }        }    }}function sendRequest(url){    createXMLHttpRequest();    XMLHttpR.open("GET",url,true);    XMLHttpR.setRequestHeader("Content-Type","text/html;charset=utf-8");    XMLHttpR.onreadystatechange = processResponse;    XMLHttpR.send(null);}function processResponse(){    if(XMLHttpR.readyState ==4 && XMLHttpR.status == 200){        document.write(XMLHttpR.responseText);    }}

调用方法 sendRequest(“www.baidu.com?id=1”)

转载于http://blog.sina.com.cn/s/blog_74f702e601013t0i.html

0 0
原创粉丝点击