使用GM_xmlhttpRequest会产生XrayWrapper拒绝访问

时间:2014-11-05 10:43:07

标签: javascript gm-xmlhttprequest

我尝试使用GM_xmlhttpRequest从跨域网页获取信息。它不断产生以下错误:

XrayWrapper denied access to property onload (reason: value is callable). 
See https://developer.mozilla.org/en-US/docs/Xray_vision for more information. 
Note that only the first denied property access from a given global object will be reported.     

代码如下:

     // ==UserScript==
     // @include        http://stackoverflow.com/
     // @grant          GM_xmlhttpRequest
     // ==/UserScript==

function GM_test4(){

console.log("test 4");

var xhr = GM_xmlhttpRequest({

    method: "GET",
    url: "http://stackoverflow.com/",
    headers: {
        "User-Agent": "Mozilla/5.0",    
        "Accept": "text/html"            
    },
    onload : function(xhr){
        if(xhr.readyState == 4){
            if(xhr.status == 200 && xhr.responseText && xhr.responseText.length > 20){
                console.log("Inside onload");
            }
        }
    },

});

}

0 个答案:

没有答案