Opening Web Pages in Your Add-On

You might not realize it, but Firefox has some mouse shortcuts for when you are opening a web page from the bookmarks toolbar. If you hold down Shift when you click, the link opens in a new window. If you hold down Command or Ctrl when you click, the link opens in a new background tab. If you hold down Command or Ctrl plus Shift when you click, the link opens in a new foreground tab. So how do you honor these different options when you are opening web pages in your add-on? You use the function openUILink.

openUILink is a helper function defined in utilityOverlay.js. It makes it easy for your addon to honor the various shortcuts that could have been used when clicking on your button or menu. All you need to do to use it is pass the url you want to open and the event to the function and it does the rest:

openUILink(url, event);

You should use this function whenever the user clicks to open a link so that they get the results they expect.

But what about if they middle click on your button or menu? There’s another helper function for this – checkForMiddleClick. This function detects a users click and converts it to the appropriate command. To use it, just add the click attribute to all your menus and buttons.

onclick="checkForMiddleClick(this, event)"

There’s one more function you might want to check out – openUILinkIn. This function lets you explicitly specify how you want the url to be opened. You can get more information on these function at

Please note: I reserve the right to delete comments that are offensive or off-topic.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “Opening Web Pages in Your Add-On