MozillaZine

Mouse Gestures - Using my own keyboard shortcut (Javascript)

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

Post Posted March 16th, 2007, 10:10 am

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

Daifne
Moderator

User avatar
 
Posts: 122994
Joined: July 31st, 2005, 9:17 pm
Location: Where the Waters Meet, Wisconsin

Post Posted March 16th, 2007, 5:23 pm

Moving to Firefox Support

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

Post Posted March 17th, 2007, 3:31 am

sorry, thanks.

m

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

Post Posted March 19th, 2007, 3:52 pm

so no one can help? :(

Guest
Guest
 

Post Posted March 19th, 2007, 4:32 pm

Try using this Javascript with a gesture:
Code: Select all
if (gBrowser.mTabs.length == 1) {
  goQuitApplication();
}

else { 
  BrowserCloseTabOrWindow();
}

Guest
Guest
 

Post Posted March 19th, 2007, 4:51 pm

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 Posted March 22nd, 2007, 4:57 am

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
 

Post Posted February 20th, 2008, 7:06 pm

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?

chrizoo

User avatar
 
Posts: 347
Joined: October 11th, 2006, 5:58 pm

Post Posted March 15th, 2008, 12:47 am

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 Posted April 1st, 2008, 3:47 am

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!!

chrizoo

User avatar
 
Posts: 347
Joined: October 11th, 2006, 5:58 pm

Post Posted April 1st, 2008, 3:51 am

no worries ;)

Guest
Guest
 

Post Posted June 6th, 2008, 9:06 am

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!

Return to Firefox Support


Who is online

Users browsing this forum: Bing [Bot] and 20 guests