Open folder in Finder or open file from HTML/browser

Discussion in 'Mac Programming' started by mike1, Aug 15, 2012.

  1. mike1 macrumors newbie

    Joined:
    Nov 9, 2007
    #1
    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.
     
  2. aagd macrumors newbie

    Joined:
    Sep 27, 2012
    #2
    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
     

Share This Page