Re: Opening a local HTML file in the default browser
Re: Opening a local HTML file in the default browser
- Subject: Re: Opening a local HTML file in the default browser
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 12 Jan 2003 10:41:10 -0800
On 1/12/03 9:56 AM, "julifos" <email@hidden> wrote:
>
> Hi,
>
>
>
> I'm creating an HTML file using AppleScript Studio. Once the file has been
>
> created, I want to open it in the user's default browser as set in the
>
> internet pane of system prefs.
>
>
>
> Using "open file", the HTML file always seems to open in Internet Explorer
>
> instead of in whatever browser is selected as the default.
>
>
>
> Using "open location" the default browser is used for URLs that start with
>
> "http:", but for those that start with "file:", again IE is always used.
>
>
>
> Since I can't seem to make a local file open in the default browser, can
>
> anyone tell me how I can determine what application the user has selected as
>
> his default browser (either by creator ID or location)?
>
>
>
> (I am using OS 10.1, in case it matters, and unfortunately, I can't upgrade
>
> to
>
> 10.2 at this point.)
>
>
>
> Thanks!
>
>
>
> Ernie
>
>
set dfb to read ((path to preferences as text) &
>
"com.apple.LaunchServices.plist" as alias)
>
set x to offset of "<key>U:http</key>" in dfb
>
set dfb to text from character x of dfb to character (x + 800) of dfb
>
set x to offset of "<key>LSBundleSignature</key>
>
<string>"
>
in dfb
>
set dfb to text from character (x + 41) of dfb to character (x + 44) of dfb
>
>
This should return creator signature of the default browser (MSIE, OPRA...).
>
Then:
>
>
tell app "Finder" to open x using app file id dfb
>
>
If this does not work (tested only here), the way you must follow is reading
>
"com.apple.LaunchServices.plist" (at user prefs), then search for
>
"<key>U:http</key>" or "<key>E:html</key>" (some guys say that this string
>
is not always there, unless the user has defined "please, finder, open every
>
html file using this app"), then for its "LSBundleSignature"...
Or you can use 'open location' with an http URL, get the application file of
the front app, and then open your file using that that app file (both in the
Finder). It's rather tacky in that the browser goes back to the 'open
location' URL if that hadn't fully loaded when you interrupt it to open the
file, so you have to put in a delay (I need 3 seconds here) to be sure
before opening the file. Odd.
set theFile to alias filePath -- if in "HD:Folder:file name" format
--set theFile to POSIX file filePath -- if in "/Folder/File Name" format
open location "
http://www.apple.com"
delay 3
tell application "Finder"
set defaultBrowser to (application file of first process whose frontmost
is true)
open theFile using defaultBrowser
end tell
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.