1
我正在編寫一個chrome擴展,它在open選項卡中注入iframe並在其中加載url。要加載的url與打開的頁面不在同一個域中標籤is.I正在使用下面的代碼:來自Chrome擴展的注入腳本中的跨域請求
--menifest.json--
"background" : {
"scripts": ["background.js"]
},
"permissions": [
"tabs", "http://*/", "https://*/"
]
--background.js--
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null,
{file:"logic.js"});
});
--logic.js--
var newdiv = document.createElement('div');
var iframe = document.createElement('iframe');
iframe.setAttribute('src','http://google.co.in');
newdiv.appendChild(iframe);
document.body.appendChild(newdiv);
這隻有當CURENT頁http://google.co.in而不是其他pages.So我打問題。但據我所知跨域,擴展可以使跨域請求,那麼怎麼做呢?請幫忙。
謝謝,它與維基百科合作。永遠不會懷疑google.co.in是罪魁禍首。 – vishesh 2013-02-12 10:23:11