osx - How to display a text file within Safari that doesn't have the .txt extension?

07
2014-07
  • jake9115

    I have some html that hyperlinks to a text file that is on my desktop. However, this file uses a different file extension than .txt, and I don't want to change it. When I view the html file in Safari and click on the link, it opens Finder and shows me where the file is, because it doesn't realize it is just a text file. Is there some way to force Safari to display the file in the browser?

    My HTML code looks like this: <a href="myTextFile.qwert">Simple test file!</a>

    Any help is much appreciated!

  • Answers
  • yoonix
    1. Right click on myTextfile.qwert.
    2. Select Get Info
    3. Go down to the Open with: section and select Safari there.

  • Related Question

    osx - How to have a timer driven "reload" of a tab in Mac OS X Safari 4?
  • AlberT

    Is there a way to have safari 4 on Mac OS X to reload a web page every N minutes on a per tab basis?


  • Related Answers
  • arathorn

    Just use a bookmarklet(a chunk of JavaScript that you can add to your bookmarks). Here's one that I found ages ago and it's served me well:

    javascript:(function(p){open('','',p).document.write('%3Cbody%20id=1%3E%3Cnobr%20id=2%3E%3C/nobr%3E%3Chr%3E%3Cnobr%20id=3%3E%3C/nobr%3E%3Chr%3E%3Ca%20href=%22#%22onclick=%22return!(c=t)%22%3EForce%3C/a%3E%3Cscript%3Efunction%20i(n){return%20d.getElementById(n)}function%20z(){c+=0.2;if(c%3E=t){c=0;e.location=u;r++}x()}function%20x(){s=t-Math.floor(c);m=Math.floor(s/60);s-=m*60;i(1).style.backgroundColor=(r==0||c/t%3E2/3?%22fcc%22:c/t%3C1/3?%22cfc%22:%22ffc%22);i(2).innerHTML=%22Reloads:%20%22+r;i(3).innerHTML=%22Time:%20%22+m+%22:%22+(s%3C10?%220%22+s:s)}c=r=0;d=document;e=opener.top;u=prompt(%22URL%22,e.location.href);t=u?prompt(%22Seconds%22,60):0;setInterval(%22z()%22,200);if(!t){window.close()}%3C/script%3E%3C/body%3E')})('status=0,scrollbars=0,width=100,height=115,left=1,top=1')
    

    And here's an edited version of this bookmarklet that removes the URL prompt and just uses the URL of the current tab:

    javascript:(function(p){open('','',p).document.write('%3Cbody%20id=1%3E%3Cnobr%20id=2%3E%3C/nobr%3E%3Chr%3E%3Cnobr%20id=3%3E%3C/nobr%3E%3Chr%3E%3Ca%20href=%22#%22onclick=%22return!(c=t)%22%3EForce%3C/a%3E%3Cscript%3Efunction%20i(n){return%20d.getElementById(n)}function%20z(){c+=0.2;if(c%3E=t){c=0;e.location=u;r++}x()}function%20x(){s=t-Math.floor(c);m=Math.floor(s/60);s-=m*60;i(1).style.backgroundColor=(r==0||c/t%3E2/3?%22fcc%22:c/t%3C1/3?%22cfc%22:%22ffc%22);i(2).innerHTML=%22Reloads:%20%22+r;i(3).innerHTML=%22Time:%20%22+m+%22:%22+(s%3C10?%220%22+s:s)}c=r=0;d=document;e=opener.top;u=e.location.href;t=u?prompt(%22Seconds%22,60):0;setInterval(%22z()%22,200);if(!t){window.close()}%3C/script%3E%3C/body%3E')})('status=0,scrollbars=0,width=100,height=115,left=1,top=1')
    
  • nik

    Safari Page Monitor.

    This configurable AppleScript keeps an eye on one or more web pages through Safari, reloading them at specified intervals and reporting any changes it detects, both verbally and through a session log file.

    The developer explains “I wrote this script to keep tabs on my brother’s home page after they had had their first baby and started posting pictures. I remembered a page-monitoring feature in the Classic version of Internet Explorer and decided Safari needed something comparable”.


    That link does not seem to work these days...
    There is an on-line alternative (unless you want to write the plugin again).


    Just be careful how and where you use this.

  • Ben Stiglitz

    You can use an AppleScript to do this. Here’s how to reload every open tab every 5 seconds:

    tell application "Safari"
        repeat
            repeat with aTab in (every tab of every window)
                set URL of aTab to (URL of aTab)
            end repeat
            delay 5
        end repeat
    end tell
    

    You can do some filtering inside the repeat with aTab block to only refresh certain tabs (predicated on the URL, title, etc.).

  • Diogo

    If you've upgraded to Safari 5 in the meantime, Apple added browser extensions. I made one that does just what you asked.

    You can take a look at it here: Auto Refresh

    Use Auto Refresh to set Safari to automatically reload on its own. Perfect for web development and monitoring online auctions, announcements and news.