Need help with a simple toolbar button

Talk about add-ons and extension development.
Post Reply
loller21
Posts: 3
Joined: November 19th, 2017, 1:28 pm

Need help with a simple toolbar button

Post by loller21 »

I made the following script following Mozilla tutorials that when I click it, it opens my url as intended.

Code: Select all

function openPage() {
  browser.tabs.update({
    url: "https://myurl.com/"
  });
}

browser.browserAction.onClicked.addListener(openPage);
What I want to accomplish is to have a bunch of buttons next to my address bar so I can navigate to the configured address. I know I can avoid all this mess by just adding toolbar shortcuts or installing a good addon, but that's not the way I want it, plus I can learn something this way.
Now the actual problem. When I click it, it opens the link in the current tab and that's fine, it should do that. When I click it with the middle mouse button though, it doesn't do anything. I want this button to open a new tab with the specified URL after I middle clicked it.
I tried researching for a while but I couldn't find anything useful, any help is appreciated.
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: Need help with a simple toolbar button

Post by morat »

A toolbar button only allows a left click, no middle or right click, no alt ctrl shift modifiers. A button in a popup allows all 3 mouse buttons with all modifiers.
loller21
Posts: 3
Joined: November 19th, 2017, 1:28 pm

Re: Need help with a simple toolbar button

Post by loller21 »

morat wrote:A toolbar button only allows a left click, no middle or right click, no alt ctrl shift modifiers. A button in a popup allows all 3 mouse buttons with all modifiers.
Thanks for replying. But the homepage button, for example, allows that kind of behavior. Is there any way to make my button work like that? I'm sorry if this sounds stupid, I really want to find out what function/event to use and how to code it
morat
Posts: 6404
Joined: February 3rd, 2009, 6:29 pm

Re: Need help with a simple toolbar button

Post by morat »

Wladimir Palant wrote:things like processing middle-clicks on our button simply aren’t possible any more
Adblock Plus browser add-on gets comfy with Firefox 57
http://adblockplus.org/blog/adblock-plu ... firefox-57

I would create a popup with multiple buttons or create a popup with multiple pages with multiple buttons on each page.

Pure Javascript Tabs with HTML5 and CSS3
http://www.my-html-codes.com/javascript ... tml-5-css3
http://www.my-html-codes.com/HTML5_tuto ... /index.php
loller21
Posts: 3
Joined: November 19th, 2017, 1:28 pm

Re: Need help with a simple toolbar button

Post by loller21 »

morat wrote:
Wladimir Palant wrote:things like processing middle-clicks on our button simply aren’t possible any more
Adblock Plus browser add-on gets comfy with Firefox 57
http://adblockplus.org/blog/adblock-plu ... firefox-57

I would create a popup with multiple buttons or create a popup with multiple pages with multiple buttons on each page.

Pure Javascript Tabs with HTML5 and CSS3
http://www.my-html-codes.com/javascript ... tml-5-css3
http://www.my-html-codes.com/HTML5_tuto ... /index.php
I guess I'll make a popup then or just end up using the default toolbar bookmarks. Thanks for replying!
Post Reply