admin管理员组文章数量:1332351
I want the link to appear in the tab beneath resulting in the popup going away.
Currently have this:
//Open links in tab from popup
if (document.location.search == '?popup')
$('a').attr('target', '_blank');
But the _blanks opens in a new tab. Any help would be greatly appreciated - thanks!
I want the link to appear in the tab beneath resulting in the popup going away.
Currently have this:
//Open links in tab from popup
if (document.location.search == '?popup')
$('a').attr('target', '_blank');
But the _blanks opens in a new tab. Any help would be greatly appreciated - thanks!
Share Improve this question asked Sep 21, 2010 at 22:35 jprimjprim 1,3632 gold badges16 silver badges22 bronze badges 01 Answer
Reset to default 7You would need to get the current selected tab first via, http://code.google./chrome/extensions/tabs.html#method-getSelected
Then you use the tab.id, that the callback has fired, and updating it with a url: http://code.google./chrome/extensions/tabs.html#method-update
For example:
chrome.tabs.getSelected({}, function(tab) {
chrome.tabs.update(tab.id, {url: 'http://google.'});
});
If you want to let every link in the popup page to update the current tab opened. You can do the following (as you mentioned within the ments but with currentTarget):
$('a').live('click', function(e) {
var href = e.currentTarget.href;
chrome.tabs.getSelected(null,function(tab) {
chrome.tabs.update(tab.id, {url: href});
});
window.close(); // To close the popup.
});
本文标签:
版权声明:本文标题:javascript - How do I have a link from a Google Chrome extension popup open in the same tab underneath? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742322074a2452990.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论