Open links in new tab in Firefox

喜夏-厌秋 提交于 2019-12-11 03:53:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!