iframe 重定向
我目前在使用 iframe 时遇到一些问题。
我的 iframe 带有搜索框,我想在单击 go 时进行此搜索框重定向...但是没有任何效果,我不明白我必须做什么...
http://img51.imageshack.us/i/issuec.png/
编辑:24/02/2011 需要明确的是,我的谷歌浏览器扩展程序调用作为内容脚本:overlay.js 然后这个将把我的“overlay.html”页面放在当前页面的末尾。
知道如何从这个 iframe 进行
。
<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>
所以问题来自于我的.html
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');
}
}
重定向
function searchBoxRedirection(form)
{
//alert(form.searching.value);
//tabs.create({url:"www.yahoo.fr"});
//parent.chrome.tabs.create({url: "http://blackweb20.com/"});
//parent.location.href='www.yahoo.fr';
//chrome.tabs.update({url:"http://www.siteduzero.com",selected:true});
//chrome.windows.create({url:"http://www.siteduzero.com"});
}
,我不
{
"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"
}
iframe
被表示为 通过使用找到答案的一部分:
function searchBoxRedirection(form)
{
window.top.location.href = "http://search.yahoo.com/search?p=" + form.searching.value;
}
但是对于创建新选项卡或新窗口,它不起作用......
I'm currently have some issue with an iframe.
I have my iframe with a searchbox and i want to make this searchbox redirection when i click on go... But nothing works and i can't understand what i have to do...
http://img51.imageshack.us/i/issuec.png/
EDIT : 24/02/2011
So to be clear, my google chrome extension call as a content script : overlay.js Then this one will put at the end of the current page my "overlay.html" page.
So the problem come from that my .html is represented as a iframe and i don't see how i can redirect from this 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');
}
}
Tool.js
function searchBoxRedirection(form)
{
//alert(form.searching.value);
//tabs.create({url:"www.yahoo.fr"});
//parent.chrome.tabs.create({url: "http://blackweb20.com/"});
//parent.location.href='www.yahoo.fr';
//chrome.tabs.update({url:"http://www.siteduzero.com",selected:true});
//chrome.windows.create({url:"http://www.siteduzero.com"});
}
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"
}
Update
I've find a part of the answer by using :
function searchBoxRedirection(form)
{
window.top.location.href = "http://search.yahoo.com/search?p=" + form.searching.value;
}
But for the creation of new tab, or a new window it didn't work...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题与以下问题完全相同(逐字):
从 Iframe 创建新的 Chrome 标签页/窗口
总而言之,您有两种选择:
This question is the exact duplicate (word by word) of:
Create a new chrome tab/window from a Iframe
To summarize, you have two choices: