LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories
User Name
Password
LinuxQuestions.org Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.

Notices


Reply
  Search this Thread
Old 03-29-2005, 08:48 AM   #1
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
firefox default browser, opening html pages in new window


I don't want to sound like a smart-ass, it's just I found the default firefox behavior irritating.

The problem:
I use firefox as the default browser in my system. I use it to surf the net and to open locally saved html pages. The problem is that if you open a locally saved html page with firefox by double clicking it, and an instance of firefox is already running in your system, the page will open in the old window, instead of opening a new window or a new tab.

Solution:
I've seen a lot of solutions for this problem, like creating a small script to do that, but IMHO just hacking the firefox script (the main executable) is the easiest and better working solution.

In most cases people install firefox somewhere like /usr/lib/firefox or /usr/local/lib/firefox or /usr/local/firefox and then place a link of firefoxe's executable in one of the /bin directories: /usr/bin or /usr/local/bin.

The main firefox executable is just a script that initializes the enviroment and maybe calls other scripts like run-mozilla.sh. The binary executable firefox-bin is never executed directly.

What all the mozilla browsers do is check if a mozilla instance is running. If not, then no problem they start it. If yes, they use the -remote option to communicate with an already running mozilla/firefox instance and execute command throught that. This way, no matter how many browser windows a user opens in a computer, they all are child processes of a basic process that has locked the default profile, and other stuff with a lock file:
Code:
skalkoto@darkstar:~/.mozilla/firefox/9x2zz9ty.default$ ls -l lock
lrwxrwxrwx  1 skalkoto users 16 2005-03-29 16:52 lock -> 192.168.10.1:348
skalkoto@darkstar:~/.mozilla/firefox/9x2zz9ty.default$
Actually if firefox is already running this part of the firefox script is executed:
Code:
########################################################################### Main
if [ $ALREADY_RUNNING -eq 1 ]; then
        # There's an instance already running. Use it.
        # Any command line args passed in?
        if [ $# -gt 0 ]; then
                # There were "some" command line args.
                if [ ${_USE_EXIST} -eq 1 ]; then
                        # We should use an existing instance, as _USE_EXIST=$_USE_EXIST=-
1
                        _remote_cmd="openURL(${_optLast})"
                        "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "${_remote_cm
d}"
                        unset _remote_cmd
                        exit $?
                fi
        else
                # No command line args. Open new window/tab
                #exec "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "xfeDoCommand(o
penBrowser)"
                "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "xfeDoCommand(openBro
wser)"
                exit $?
        fi
fi
The solution is to change _remote_cmd="openURL(${_optLast})" to
_remote_cmd="openURL(${_optLast} , new-window)" or
_remote_cmd="openURL(${_optLast} , new-tab)"

This is the $Id: mozilla.in,v 1.3.4.9 2004/10/26 09:26:11 bryner%brianryner.com Exp $
script used by firefox 1.0.1 and 1.0.2. , maybe by 1.0 also. I don't know about older scripts, but they should be similar. I'm using slackware 10.1 and firefox 1.0.2, the one packed by Pat in slackware-current, if it matters at all (which I don't think it does).

for more info on the -remote option follow this link:
http://www.mozilla.org/unix/remote.html

Thanks for your patience

Last edited by perfect_circle; 03-29-2005 at 08:50 AM.
 
Old 03-29-2005, 09:11 AM   #2
ahh
Member
 
Registered: May 2004
Location: UK
Distribution: Gentoo
Posts: 293

Rep: Reputation: 31
I dont have Firefox installed as I use Galeon, but they are both based on Mozilla so maybe this will help.

galeon -x (load in existing window)
galeon -w (load in a new window)
galeon -n (load in a new tab)

I'm sure Firefox must be just as advanced seeing that it won browser of the year on this very forum
 
Old 03-29-2005, 10:00 AM   #3
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Original Poster
Rep: Reputation: 53
Quote:
Originally posted by ahh
I dont have Firefox installed as I use Galeon, but they are both based on Mozilla so maybe this will help.

galeon -x (load in existing window)
galeon -w (load in a new window)
galeon -n (load in a new tab)

I'm sure Firefox must be just as advanced seeing that it won browser of the year on this very forum
in mozilla or firefox something like
firefox -remote "openURL(www.google.com)"
firefox -remote "openURL(www.google.com, new-window)"
firefox -remote "openURL(www.google.com, new-tab)"

should do the job
 
Old 03-29-2005, 10:26 AM   #4
ahh
Member
 
Registered: May 2004
Location: UK
Distribution: Gentoo
Posts: 293

Rep: Reputation: 31
Well, what I was thinking was, if I wanted to open local files in a new window with Galeon I would just associate the html files with "galeon -w" in the file manager. As it is I use "galeon -n", so any html file is opened in a new tab if Galeon is already running.

It saves having to edit scripts, and is easy to change at any time, or for different types of file.

But unless there are options available for Firefox that dont require the URL to be enclosed in brackets, and dont require something to be written after the URL I guess it's not an option for you.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Open HTML file in default browser through C++ Last Attacker Linux - General 10 10-20-2005 12:32 PM
Firefox runs slow when serving up HTML Pages lennysokol Linux - Software 2 05-16-2005 08:25 PM
How to stop KDE from opening CD/DVD browser window? cheesekeeper Linux - General 2 05-04-2005 12:13 AM
Firefox: prevent opening a new window evilmonkey Linux - Software 6 10-30-2004 11:50 AM
Cookie Sharing Between CGI generated HTML pages and standard HTML pages rkwhited Linux - Newbie 5 08-15-2004 07:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories

All times are GMT -5. The time now is 03:51 PM.

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