问题
I am developing an Firefox extension. How can all the links on a webpage to be opened in a new tab?
回答1:
That's usually a configurable option in Firefox to handle new links, so they may override your extension with that.
However...
The code
<a href="http://www.example.com/"> Example Website</a>
will allow you to click the appearing words [Example Website], and the link will open in the current window.
The code
<a href="http://www.example.com/" target="_blank"> Example Website</a>
Opens the link in a new window/tab.
The only mildly dodgy thing is that target is now apparently deprecated by the W3C, which means that it's generally up to the browser ( and the user's preferences) as to how (or even if) it is handled. But for people who have their preferences set accordingly - in Firefox - that should work.
回答2:
I found what I was after. I wanted gbrowser.addtab(this.href).
回答3:
Press Ctrl while clicking on the link on Windows. Use cmd on OSX.
来源:https://stackoverflow.com/questions/1716645/open-links-in-new-tab-in-firefox