最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - open a link in a new tab in the same window - Stack Overflow

programmeradmin1浏览0评论

Hi I am making a firefox extension which needs to open a link in anew tab in the same window of firefox. How should i do this? This opens in a new window (replacing the old window):

window.location = url;

This opens in the same tab

window.content.document.location = url

Any idea on how to open the url in a new tab?

Hi I am making a firefox extension which needs to open a link in anew tab in the same window of firefox. How should i do this? This opens in a new window (replacing the old window):

window.location = url;

This opens in the same tab

window.content.document.location = url

Any idea on how to open the url in a new tab?

Share Improve this question asked May 11, 2010 at 6:18 encryptorencryptor 3731 gold badge4 silver badges15 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

Have you tried window.open(url)? I'm guessing opening specifically in a new tab (as opposed to a new window) is part of the browser behavior that can't be controlled via JavaScript.

This works guys! :))

var wm = Components.classes["@mozilla/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator);

var mainWindow = wm.getMostRecentWindow("navigator:browser");

mainWindow.gBrowser.selectedTab = mainWindow.gBrowser.addTab("http://google.");
发布评论

评论列表(0)

  1. 暂无评论