Mouse Gestures - Using my own keyboard shortcut (Javascript)

User Help for Mozilla Firefox
Post Reply
martynonline
Posts: 4
Joined: March 16th, 2007, 10:04 am

Mouse Gestures - Using my own keyboard shortcut (Javascript)

Post by martynonline »

Hi all,
I use Mouse Gestures extension and would very much like to be able to close tabs but in such a way that when the last tab is closed the entire browser closes. The only way I can think of doing this is by mapping a keyboard shortcut in Mouse Gestures to 'ctrl+w'. Only problem is I don't know how to do this using Javascript.

Can anyone help?

Thank you in advance oh internet community you!

martyn
User avatar
Daifne
Moderator
Posts: 123071
Joined: July 31st, 2005, 9:17 pm
Location: Where the Waters Meet, Wisconsin

Post by Daifne »

Moving to Firefox Support
martynonline
Posts: 4
Joined: March 16th, 2007, 10:04 am

Post by martynonline »

sorry, thanks.

m
martynonline
Posts: 4
Joined: March 16th, 2007, 10:04 am

Post by martynonline »

so no one can help? :(
Guest
Guest

Post by Guest »

Try using this Javascript with a gesture:

Code: Select all

if (gBrowser.mTabs.length == 1) { 
  goQuitApplication();
}

else { 
  BrowserCloseTabOrWindow();
}
Guest
Guest

Post by Guest »

Sorry, I misread your post. You want a keyboard shortcut to do that. I'm not sure how one would do that with Mouse Gestures.

You can install the userChrome.js extension:
http://forums.mozillazine.org/viewtopic.php?t=397735

Restart Firefox

Add the following to userChrome.js in your profile:

Code: Select all

(function() {

var cW = document.getElementById('cmd_close');

cW.setAttribute('oncommand', 'if (gBrowser.mTabs.length == 1) { goQuitApplication(); } else {  BrowserCloseTabOrWindow();}');

})();

That will allow you to use Ctrl-w to close tabs and then the application if only one tab is open.
martynonline
Posts: 4
Joined: March 16th, 2007, 10:04 am

Post by martynonline »

Excellent!!! Your first answer was the one I was looking for!! Thank you so so much for taking time to help me.

Long live open source, long live Firefox!

:D
Alexbr1
Guest

Open link in new tab, never blank

Post by Alexbr1 »

I use mouse gestures all the time but I'd like to change a setting.
The default behaviour of mgB_OpenBlankOrLinkTab is open link in new tab, if no link is present it will open a new blank tab.

I always end up opening a new blank tab by mistake so I need a custom javascript gesture to just open a link in new tab, without opening a blank tab if no link is present.

Can somebody help me?
User avatar
chrizoo
Posts: 374
Joined: October 11th, 2006, 5:58 pm

Post by chrizoo »

no problem:
<a href="mozgest://addmapping/browser/RU;RUU/custom/!link%3A%20open%20hovered%20in%20tab/if%20(globalOnLink%20%26%26%20globalOnLink.length%20%3E%200)%20%7B%0A%20%20window.getBrowser().addTab(globalOnLink%5B0%5D)%0A%7D%0A/">!link: open hovered in tab (RU)</a>
Guest
Guest

Post by Guest »

chrizoo wrote:no problem:
<a href="mozgest://addmapping/browser/RU;RUU/custom/!link%3A%20open%20hovered%20in%20tab/if%20(globalOnLink%20%26%26%20globalOnLink.length%20%3E%200)%20%7B%0A%20%20window.getBrowser().addTab(globalOnLink%5B0%5D)%0A%7D%0A/">!link: open hovered in tab (RU)</a>


Hi chrizoo

That was exactly what I was looking for.
Thank you very much!!
User avatar
chrizoo
Posts: 374
Joined: October 11th, 2006, 5:58 pm

Post by chrizoo »

no worries ;)
Guest
Guest

Post by Guest »

Hi. I am trying to use mouse gestures to assign a keyboard short cut to button 3 on my mouse. I can't figure out the js for the gesture. Any help? The shortcut key is "Alt+`" Thanks!
Post Reply