【发布时间】:2011-07-04 04:33:18
【问题描述】:
我目前对 iframe 有一些问题...
我有一个带有搜索框的 iframe,我想在单击 go 时通过创建一个新选项卡/窗口来重定向这个搜索框
http://img51.imageshack.us/i/issuec.png/
所以要清楚,我的谷歌浏览器扩展调用作为内容脚本:overlay.js 然后这个将把我的“overlay.html”页面放在当前页面的末尾。
所以问题来自我的 .html 被表示为 iframe,我看不到如何从这个 iframe 重定向。
overlay.html
<form id="searchForm" action="#" onsubmit="searchBoxRedirection(this)" method="post">
<img id="logo" src="images/extension.png" alt="Logo"></img>
<input type="search" value="" name="searching">
<input type="submit" value="Go !" />
</form>
overlay.js
var overlay= {
init: function() {
this.injectoverlay();
//alert('Initialisation reussie');
},
injectoverlay: function() {
var body = $('body'),
overlayURL = chrome.extension.getURL("overlay.html"),
iframe = $('<iframe id="YouroverlayFrame" src="'+overlayURL+'">');
body.append(iframe);
iframe.show();
//alert('Injection reussie');
}
}
工具.js
function searchBoxRedirection(form)
{
tabs.create({url:"www.yahoo.fr"});
}
manifest.json
{
"background_page" : "background.html",
"browser_action" :
{
"default_icon" : "images/Extension.png"
},
"content_scripts":
[ {
"all_frames": true,
"css": ["css/overlay.css"],
"js": ["js/overlay.js"],
"matches": ["http://*/*"],
"run_at": "document_start"
} ],
"permissions" : ["tabs", "unlimitedStorage", "http://*/*"],
"name" : "MyOverlay",
"version" : "1.1",
"description" : "Sindar Overlay"
}
【问题讨论】:
标签: javascript iframe google-chrome google-chrome-extension