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