![](/img/trans.png)
[英]Greasemonkey: “GM_xmlhttpRequest is not defined” with the new update
[英]Getting GM_xmlhttpRequest is not defined in Greasemonkey script (Firefox 21.0)
這是我的代碼:
// ==UserScript==
// @name Test1
// @namespace http://my_unique_namespace.com
// @version 1
// @include http*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_log
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// ==/UserScript==
function testReq() {
GM_xmlhttpRequest({
method: "GET",
url: "http://www.google.com",
onload: function(response) {
alert(response.responseText);
},
onerror: function(reponse) {
alert('error');
}
});
}
testReq();
GM_log("This works");
/*
Exception: GM_xmlhttpRequest is not defined
testReq@Scratchpad/1:15
@Scratchpad/1:27
*/
我的問題是,每次運行腳本時,都會在代碼示例的底部列出該異常,但是GM_xmlhttpRequest似乎正在運行(我成功獲取了響應對象)。
任何想法為什么會這樣?
謝謝。
更新:Windows 7 Professional 64位上的Greasemonkey 1.8
這發生在1個月前的Fedora 17的google-chrome-beta.i386中。 已安裝google-chrome-stable.i386。 問題已解決。
對於chrome穩定的最新更新,此問題再次發生。 版本是27.0.1453.93。
運行GM_xmlhttpRequest的相關腳本是手動安裝到Extensions中的.user.js腳本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.