+ -
当前位置:首页 → 问答吧 → xmlHttp 在ie firefox chrome 里兼容的问题

xmlHttp 在ie firefox chrome 里兼容的问题

时间:2011-02-03

来源:互联网

这个是我的 test.html
JScript code

        var url = "";
        var xmlHttp = false;
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e2) {
                xmlHttp = false;
            }
        }
        
        if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
            //alert()
            xmlHttp = new XMLHttpRequest();
        }
        xmlHttp.open("get", url, true);
        xmlHttp.onreadystatechange = callBack_Check;
        xmlHttp.send(null);
        
        function callBack_Check(){
            // 4代表服务器端执行完毕并已经成功返回
            if (xmlHttp.readyState == 4) {
                //通过responseText属性得到服务器端实际返回的文本
                alert(xmlHttp.responseText);
            }
        }



现在当我在 url 里输入 test.html(就是本页面) 3个游览器 都可以获取网页源代码
如果我在 url 里输入 ajax.html (同级页面) 可以在 ie 和firefox 中显示源代码
当我在 url 里输入 http://www.google.com 的时候 只有在 ie 下可以显示源代码

我主要目的就是想要在 chrome 中显示 www.google.com 的源代码 试了半天 得出上面的规律 
有谁知道原因 帮下忙 ajax本人不是很懂

作者: zwl230631   发布时间: 2011-02-03

不行~

作者: KK3K2005   发布时间: 2011-02-03

楼上太那个了

作者: zwl230631   发布时间: 2011-02-03

热门下载

更多