How can I close a specific browser window under linux
May 5, 2008 9:19 AM   RSS feed for this thread Subscribe

Can I control a browser from an application under linux.

My application has an option to run as an http server, and kick off a browser that points to itself using (for example) /usr/bin/mozilla.
I want to add a quit button to the generated html, which tells the application to quit serving, then closes the browser, window, or tab that was created.
Obviously I dont want to quit any other windows or tabs if the user is doing something else at the time.
Stopping the server is no problem, but I'm hitting a roadblock closing down the browser side. Javascript wont let me close the current window, and I cant find any command line options to mozilla that let me do what I want.
Is there something I'm missing, or a better approach to the problem?
posted by yetanother to computers & internet (6 comments total)
Rather than "remotely controlling" the browser, couldn't you have the script that starts it also kill it?

You could have the "quit" button send a signal to the backend daemon you've written, which would read the process ID Firefox got started as (since it started it!) and send a kill signal to it.

The big wrinkle is that they may very well have opened other tabs and be irritated. I think it may be better design to just display a, "The server has been stopped. You may now close your browser window" message. I don't know the specifics, but I'd be annoyed if the browser just closed.
posted by fogster at 9:36 AM on May 5


record the pid when mozilla is launched, and have the server kill the process via the pid before it shuts down.
posted by jrishel at 9:36 AM on May 5


When the browser process is started, store the browser's process ID. When the user hits to quit button, use the PID to kill it.
posted by Blazecock Pileon at 9:37 AM on May 5


Recording the PID wont work, for the reasons outlined by fogster - I really don't want to kill any other windows that have been opened, or that were open before mine.
posted by yetanother at 9:41 AM on May 5


You could embed an HTML rendering engine inside your own client application, and then you don't have to worry about Mozilla.
posted by Blazecock Pileon at 9:43 AM on May 5


I think fogster's "And now you can close this window" suggestion is spot-on. I, for one, would be somewhere between annoyed and angry if my browser killed itself - in particular, I'd want to see "The server successfully shut down" so I know that, y'know, my browser didn't just crash on me.
posted by Tomorrowful at 9:49 AM on May 5


« Older I just got a juicer. Now what ...   |   When I die, I want to make sur... Newer »

You are not logged in, either login or create an account to post comments



Related Questions
Help me not download .pdfs I don't want! September 19, 2007
Curb my internet addiction August 16, 2007
Firefox 2.0 Not Working October 26, 2006
Three-column two-line layout in Thunderbird? September 25, 2006
Web browser market share reference July 20, 2006