Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mike1

macrumors newbie
Original poster
Nov 9, 2007
5
0
Hi,

Is there a way to have an hyperlink in an HTML document and possibly Javascript function that when clicked opens a file using the OS X default application or a folder in Finder. For instance: Clicking a link that would cause a text file to open TextWrangler, or clicking a link to a path that opens a Finder window at that location.

I tried these but they don't work:
Code:
<a href="/Users/mike/Desktop/test.txt">test</a>
<a href="file://localhost/Users/mike/Desktop/test.txt">test</a>
<a href="Macintosh HD:Users:mike:Desktop:test.txt">test</a>

The first two open the text file in the browser window and the third produces an error page in the browser.

As for opening a folder:

Code:
<a href="/Users/mike/Desktop/">test folder</a>

This correctly opens the Finder window in Safari (cool), but Chrome and Firefox just display a directory listing in the browser window.

I realize this is probably based on security reasons for browsers and OS's and so it's probably wouldn't be a straightforward process, but it's for an internal/local page for my personal use, so if it involved third-party software or browser extensions that would be fine with me.

I googled this but it's hard to find info about it because the search terms end up together a lot in articles that are unrelated to my issue. Thanks for any help you can give.
 
According to Frank Woolsey from Bare Bones Software this is not supported - at least not by an URL scheme.
Original Thread

I'd recommend to open text files in TextMate instead, using this scheme:
txmt://open?url=file:///Users/YourUsername/Desktop/yourfile.txt
URL Scheme @ TextMate Manual
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.