[英]Iframe Redirection
我目前在使用iframe時遇到問題。
我的iframe帶有搜索框,我想在單擊“轉到”時進行此搜索框重定向...但是沒有任何效果,我無法理解我該怎么做...
http://img51.imageshack.us/i/issuec.png/
編輯:2011年2月24日所以要清楚一點,我作為內容腳本的Google chrome擴展程序調用: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');
}
}
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"
}
更新資料
我使用以下方法找到了答案的一部分:
function searchBoxRedirection(form)
{
window.top.location.href = "http://search.yahoo.com/search?p=" + form.searching.value;
}
但是對於創建新標簽或新窗口來說,它不起作用...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.