scripting default browser/open location

I want to be able to open several internet addresses in separate browser windows–independent of the browser.
I know there is the standard addition “open location” command, but that doesn’t allow you to tell the browser to open in a new window.
Is there a work around? I could, if necessary, have separate tell blocks for each of the major browsers, but then how can I get the default browser set in the Internet Pref pane (in OS X)?

i am not sure about osx - but for os9 you can get the default browser by simply using this…

open location ""

hope this helps…

This doesn’t really “get” the default browser. it “uses” the default browser. I think the goal is to find out which browser is set as the default.


Very true. Also:

<P style="white-space:nowrap;font:normal 10px/13px Geneva">«event GURLBROW»

will launch the default browser (w/o opening a URL), but you’d then have to list the active processes with the Finder and pick out the application’s name/path/id.

This was presented as a solution a long time ago in this forum: Use the raw event shown above to launch the user’s default browser. Script the Finder to wait a moment or two (and allow the application to launch and come to front), and then get the name/path/id of the frontmost application.

I think it would fail if the user clicks on another application (desktop, window of another app, etc.) while the Finder is waiting to make sure the browser application has had time to launch.

how can I get the default browser set in the Internet Pref pane (in OS X)?
: Thanks.

Now that you’ve split these openURL cmds out for each browser, why not use a generic open command first, then wait a few seconds, then get the front application, and then address the next openURL commands to that app.

tell application "Finder" to open location ""
delay 2
tell application "Finder" to set fm to name of (processes) whose frontmost is true
if fm = etc. ( your script )

Eelco Houwink

I guess you 'll have to read out the file
DefaultHelperApps.plist that resides in:
that resides in:
Eelco Houwink

inelegant, but that helps. Thanks. Do you know of a preferred way to get the “web” key with some kind of event? Or do I have to read in the file and search for :

web = (
DisplayName = "Internet Explorer";
Info = { BundleIdentifier = ""; };
IsDefaultHandler = YES;

or something? hmmm…

Sounds good. But I want a generic sub-routine. To do that technique, I’d have to be able to open a random web page first, which would not be very good design. besides, it would defeat the original reason I didn’t want to use “open location”: it won’t open a location in a new browser window (for most browsers).

The other problem with getting the info in “/System/Library/PreferencePanes/Internet.prefPane/Contents/Resources/English.lproj/DefaultHelperApps.plist” is that it depends on an english localization.
now i’d have to find out what language was being used first.
there must be a better way.

I can’t even figure out to refer to that file in apple script.
this doens’t work

tell application "Finder"
set thefile to file "System:Library:PreferencePanes:Internet.prefPane:Contents:Resources:English.lproj:DefaultHelperApps.plist" of startup disk --as alias
open for access thefile
set thestring to read thefile using delimiter {"web = (", "}"}
close access thefile 
end tell 
set result to thestring

how do you refer to a unix path without naming the volume in apple script?

You’ll have to change the line that reads the file delimited, since it didn’t work for me, but to open and have access to the file, try this:

tell application "Finder"
   set startupDiskName to (startup disk as string)
end tell

  set theFileHandle to open for access file (startupDiskName & "System:Library:PreferencePanes:Internet.prefPane:Contents:Resources:English.lproj:DefaultHelperApps.plist")
  set webString to read theFileHandle using delimiter {"web = (", "}"}
  close access theFileHandle
  return webString
on error errMsg number errNum
      close access theFileHandle
  end try
  display dialog errMsg & ": " & errNum
end try

Thanks. But this is Crazy! I just noticed that the file to which we are referring here doesn’t even contain my defaults… If I go to system prefs, my default e-mail and newsreader clients appear in the pop up menu as expected. However, if I open that file, it does not even mention either client. (By coincidence only perhaps I’m using Explorer as my web browser.)

Very odd.

there’s got to be a way to do this.