Open local file in browser


I have a script that needs to open a HTML file that resides on the local desktop. I would use the Finder but, if someone has their HTML files set to open in BBEdit or something other than a browser, it won’t work. What’s a generic way to do this? Can I use ‘open location’ from Standard Additions? If so, how do I construct the URL using a regular file path?

Thanks. :slight_smile:

Thanks! With your help and a bit of experimentation, I seem to have something that works. :slight_smile:

hi, rob…
This is a little tricky, but you can get the default browser of the user by reading a file called “”, located at preferences folder.

You must look for “U:http” and read some extra characters to get this text:


(note that all carriage returns here are not carriage returns, but line feeds (ascii char 10)
A little exercice of read/parse text will give you not the name, but the creator of the default browser, which is cool for “tell app finder to open x using app file id y”…

Thanks JJ. Maybe I’ll play with this and Late Night Software’s XML Tools. I’ll need to learn this XML/plist stuff sooner or later, so now is a good time to do it. :slight_smile:

off topic slighty but does someone have a link to a good xml editor seeing as pepper has gone the way of the dodo…

I like both bbedit & dreamweaver…

Never tried “FrameMaker”
Some people like OxYgen (
Also, some links to check: (applescriptable)

Howdy Rob,

I’m just throwing this out there, but what about Peter Bunns stuff? He spent a long time refining that, and it appears to work very well. Even if you didn’t use it altogether, perhaps some of the code might shed some light on what your trying to accomplish.

Just a thot. :wink:

I agree that Peter has done an excellent job with Missing Link but I alread found what I needed. Thanks anyway! :slight_smile: