LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-16-2006, 03:44 AM   #1
albatros_la
LQ Newbie
 
Registered: Sep 2004
Posts: 13

Rep: Reputation: 0
Javascript:closing Firefox command


Is there a way to close the entire Firefox window through a javascript command? I've found out this:
Code:
<button onclick="javascript:window.close()">Close</button>
which works good but closes only the last tab opened an not the whole browser window if there are more than one tabs.

Thanks in advance for the help...
 
Old 08-16-2006, 03:54 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
I don't think so, javascript is supposed to target only windows it has control to, for security reasons.
 
Old 08-16-2006, 04:52 AM   #3
albatros_la
LQ Newbie
 
Registered: Sep 2004
Posts: 13

Original Poster
Rep: Reputation: 0
Thank you jlliagre. I'm writing a bash script and I want to close the whole window. So I supposed to do that through javascript making firefox load a page with that command within. Do you know any other way to close selectively a window without killing the entire process? I've tried with xkill -id window_id, but it kills firefox-bin and so the other windows opened. It's a strange trouble because firefox doesn't open multiple instances but a process only without any parents, so it's hard to control windows from outside the task!
 
Old 08-16-2006, 11:45 PM   #4
dinojerm
Member
 
Registered: Apr 2004
Location: NJ,US
Distribution: Debian Sid
Posts: 33

Rep: Reputation: 15
Firefox does have a BrowserCloseWindow() function in its browser.js file, but it can only be called by the browser itself or by an extension. While it is fairly simple to create an extension that will close the window when at the press of a toolbar button or something like that, I don't know of a way to run code from an extension from the command line.
 
Old 08-17-2006, 03:53 AM   #5
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Rep: Reputation: 38
Intressting. I need some thing similar.
 
Old 08-24-2006, 08:21 AM   #6
albatros_la
LQ Newbie
 
Registered: Sep 2004
Posts: 13

Original Poster
Rep: Reputation: 0
Maybe there's a simpler way to send commands directly to firefox. It acts something like a dcop server. Googling outthere I've found bash strings like:
Code:
firefox -remote 'ping()'
or
Code:
firefox -remote 'openURL(www.google.com, new-window)'
If anyone knows how that works, maybe it's possible to use such a syntax in order to control the browser internal functions... Unluckyly I didn't find nothing but those examples above!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
firefox instances closing bong.mau Linux - Software 1 06-09-2006 05:15 PM
Firefox 1.5 keeps closing after installing java plugin TCD511 SUSE / openSUSE 7 04-25-2006 09:18 PM
javascript in firefox jackdoll Fedora 1 11-19-2005 02:18 AM
Mozilla Firefox closing abruptly mufy Linux - General 5 03-17-2005 10:53 AM
javascript for firefox? mohapi Fedora 4 06-20-2004 03:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration