So I created a .webloc file using a .vncloc file as a template (standard xml/plist format), but instead of opening in a Safari window, it is downloading the html of the website into a file.

My goal is to eventually write a cronjob that keeps the URL of a server with a dynamic IP address up to date in the file (in dropbox) so that I can just double-click it anytime and get the correct server page.

The contents of the file look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

How do I get the .webloc file to actually open and display in Safari, as if I were to have entered the URL myself?

  • Oh yeah, and if I create a webloc file by dragging the URL to the desktop, it's not in this xml/plist format and contains weird characters, which makes me wary about maintaining it via script.
    – hepcat72
    Apr 14 '15 at 20:27
  • 2
    webloc files written by Safari have a data fork and a resource fork, which is binary (the "weird characters"). See this. Google Chrome creates them here (search that page for WriteURLToNewWebLocFileResourceFork). That said, I tested creating a webloc with your XML above, substituting this site's address. It opened correctly in both Chrome and Safari. Are you sure your webserver is sending the correct headers?
    – tubedogg
    Apr 14 '15 at 21:01
  • I haven't checked the headers. I thought about that, but I figured that if the site loads fine when you type the URL into the location field, shouldn't it load file in the browser if you open the .webloc file? I'll check the headers. That's got to be it, but why would behavior be different between location field and .webloc file?
    – hepcat72
    Apr 15 '15 at 21:28
  • No idea. The behavior should be identical. What version of Safari? Did you test in Chrome or Firefox just to see what happens?
    – tubedogg
    Apr 15 '15 at 21:30
  • Safari 7.1. Didn't think to try to open the .webloc file in another browser. Not sure that should work, but I tried it using FireFox and got an XML parsing error. It didn't like the parameters at the end of the URL string. Perhaps I need to make the special characters in the URL XML-safe. The web page opens fine in FireFox though by typing it in the location field, if that's what you meant.
    – hepcat72
    Apr 15 '15 at 23:17

You must log in to answer this question.

Browse other questions tagged .