Using Firefox with Web Applications
While Javascript isn't quite (and likely never will be) ready for running entire websites any more than Flash is, it's quickly becoming a popular language for writing browser-based applications. The advantages are aplenty: the bulk of the data processing is done at the client, so it's fast. There's no waiting for your browser to download, render, and display a page every time you click a link. And since it runs in a web browser, deployment, upgrades, bug fixes, and configuration become non-issues.
There's something about browser-based applications that some programmers just don't like though. And that is that browser-based applications are ... well ... browser-based. Fortunately, there are a few techniques that one can use to make a webapp act just like a regular desktop application, and this article is about the technique I've developed.
But, first, a quote from my good friend and former systems administrator Jacob to sum up everything:
"We've got interaction, we've got speed, we've got...a browser window open. I don't know how to describe it, but when my eyes see a browser window open, my brain thinks website. No matter how it tries to sell it, my brain still thinks it's a website. It could scream webapp at me, and my brain would still say it's a website. Why? Because...well...it looks like a website. There are my forward/back/stop/refresh buttons, there's the browser location bar. It's a website."
Well, I couldn't agree more. Fortunately, Firefox, a web browser developed by Mozilla that's basking in plenty of word-of-mouth advertising from disgruntled Internet Explorer users, has some great features we can use to get around this. Hiding the address bar, the navigation toolbar, the bookmarks toolbar, and the status bar are easy. But what about when we want to get back to our regular web browsing?
Let's create a profile in Firefox that we'll only use for our webapp. That way, we can change whatever settings we like, and not disturb our default profile. And best of all, with a little VBScript, we can run the two side-by-side, both at the same time.
First, let's load the Firefox profile manager. There might be a shortcut for this in your Start Menu; otherwise run firefox.exe -ProfileManager from the command line. Note that Firefox will need to be closed for you to do this. Creating a profile is fairly self-explanatory, so I won't go into it here. But go ahead and do that now, and adjust all the settings that you think you need to, so that your webapp is as comfortable as possible.
IMPORTANT WARNING: There has been a well-documented bug since 1999 in the Mozilla Profile Manager. If you create a profile in a folder, then delete the profile, the profile manager deletes all the files in the folder. If you create a profile in your root C:\ drive for example, this could be disastrous. Always put profiles in their own, empty folder.
Now that your profile is ready to go, we need a technique for running it alongside your default profile. Right out of the proverbial box, Firefox won't let you run two profiles at once. But that's what MOZ_NO_REMOTE is for. MOZ_NO_REMOTE is an environment variable. If Firefox sees this variable set, it'll run independent of the rest of your computer. It won't care about Firefox already running, and if you click a web address in another application, it won't try to open the link in the Firefox instance that's been run with MOZ_NO_REMOTE - perfect for webapps!
The following VBScript is great for setting the variable, loading Firefox, and unsetting it. Copy this to a text editor and save it with the extension .vbs. Yes, this can be done with a batch file, but the VBScript technique eliminates the command prompt box popping up.
' The following variables should be self explanatory. FirefoxProfile = "MyProfile" FirefoxPath = "c:\progra~1\mozill~1\firefox.exe" webappurl = "http://www.toao.net/" ' Create the Wscript.Shell object. set wshshell = CreateObject("Wscript.Shell") ' Set the environment variable MOZ_NO_REMOTE to 1. This allows us to run multiple Firefox profiles at once and ensures that opening shortcuts etc does not interfere with our webapp. set env=WshShell.Environment("Process") env("MOZ_NO_REMOTE") = "1" ' Load FirefoxPath with the profile FirefoxProfile and have it go to the URL webappurl (these three variables are defined above.) wshshell.run FirefoxPath & " -P " & FirefoxProfile & " " & webappurl ' Clear the MOZ_NO_REMOTE variable. It's not enough to set this to 0; it must be cleared entirely. (This took me a while to figure out.) on error resume next env.Remove "MOZ_NO_REMOTE"






