Firefox javascript tab closure command?
January 12, 2008 11:13 AM   Subscribe

Firefox javascript command: how to close a tab? Last week you helped me create a toolbar bookmark for scrolling down a half page in Firefox using the command javascript:self.scrollBy(0,300); as seen here. Now I'd like to add a second command to that bookmark: a command to close the active tab. The button then would close the active tab and subsequently scroll down a half page of the next tab that appears. In my reading there appears to be some difficulty making using javascript to close tabs in FF 2.0, and not all pre FF 2.0 solutions currently work. Ideas?
posted by bbranden1 to Computers & Internet (5 answers total)
Do you need a bookmark, or can you just press Ctrl-F4 and PageDown once?
posted by blue_beetle at 1:51 PM on January 12, 2008

javascript:self.close() ?
posted by misterbrandt at 2:56 PM on January 12, 2008

oh, but then i don't think that bookmark will be able to interact with the next active tab...
posted by misterbrandt at 2:57 PM on January 12, 2008

Response by poster: It should be a bookmark so all the actions can be accomplished via one button click, no extra hand movements required.
posted by bbranden1 at 3:01 PM on January 12, 2008

Can't be done normally, unless the tab was opened by, e.g.

function openMyWindow(){
// Open new window
MyWindow ='mypage.html');

function closeMyWindow(){
// Close previously opened window

Methods that worked in previous versions of FF (e.g. window.close(); window.focus();) did so by exploiting minor security bugs. I suspect you'll need to look into signed code in order to close arbitrary tabs you didn't explicitly create yourself. You'll also need to look into the whole UI DOM (remember, the whole UI in FF is effectively one big document; tabs & child windows are subdocuments) to reference/change the currently focused window.

(To avoid accusations of Male Answer Syndrome: It's been a really long time since I looked into this, but that's how I remember it working.)
posted by Pinback at 3:44 PM on January 12, 2008

« Older Transportation and domestic help options for an...   |   What tools exist for OS X to manage my music... Newer »
This thread is closed to new comments.