我想送在Chrome瀏覽器HTTPGET請求,但我得到這個錯誤 資源必須在web_accessible_resources清單關鍵Chrome擴展的資源必須在web_accessible_resources清單項中列出
這裏上市是我的按鈕代碼
contentInput.onclick = function(){
var assetid = $('.thumbnail-span').attr("data-3d-url")
var baseurl = 'http://www.roblox.com'
var xhr = new XMLHttpRequest();
xhr.open("GET", chrome.extension.getURL(baseurl + assetid), true);
var result = xhr.responseText;
xhr.send();
console.log(result)
chrome.extension.sendRequest({
action: "EditContent",
type: assetType,
name: assetName,
content: contentData
})
和我的清單文件
{
"name": "ROBLOX Object Downloader .obj",
"short_name": "OBJDownloader",
"description": "Allows you to quickly download assets from the browser as a .obj ",
"version": "1.0.0",
"icons": {"128":"icon.png"},
"permissions": [
"http://*.roblox.com/*",
"http://*.rbxcdn.com/*",
"downloads",
"downloads.open"
],
"background": {"scripts":["background.js"]},
"content_scripts": [
{
"matches": ["http://*.roblox.com/*-item?id=*"],
"js": ["item.js","jquery.js"]
},
{
"matches": ["http://*.roblox.com/*ser.aspx*"],
"js": ["user.js","jquery.js"]
},
{
"matches": ["http://*.roblox.com/*atalog/*"],
"js": ["cataloginsert.js","jquery.js"]
}
],
"manifest_version": 2
}
好吧,那爲什麼'VAR由assetid = $ ATTR( 「數據-3D-URL」) VAR的BaseURL = 'http://www.roblox.com' var xhr = new XMLHttpRequest(); xhr.open(「GET」,baseurl + assetid,true); var result = xhr.responseText; xhr.send(); console.log(result)'不顯示結果? IT只是顯示XHR完成加載:GET和另一行是空白的 – user3851593 2014-09-02 20:03:05
@ user3851593您不需要等待異步調用完成;我編輯了我的答案。 – apsillers 2014-09-02 20:09:47
@ user3851593請不要嘗試在評論中粘貼多行代碼。它看起來_bad_。 – Xan 2014-09-02 20:11:36