If you double-click a .url file in Snow Leopard, it will open in Safari. To get it to open in Firefox:
- Open the Applescript editor
- Paste in the Applescript below (courtesy of this Stack Overflow post)
- Save it as an application
- In the finder, select a .url file
- Choose
Get Info from the File menu
- Specify this new application under Open With
- Click on
Change All, and confirm the action
To open a .webloc file in Firefox in XP, I made a C# application:
- Open Visual Studio. Express versions are free from Microsoft.
File menu -> New -> Project
- Select
Console Application. Name it. Ok
- In the
Solution Explorer, right-click on the project name -> Properties
- Output type:
Windows Application. This is so when Windows opens your console app, no console window is displayed
- Paste the below C# program into
Program.cs
Build menu -> Build Solution
- Double click on a .webloc file. When it asks what program to use, select from list then browse to the new exe you just made
Applescript:
on open the_droppings
set filePath to the_droppings
set fileContents to read filePath
set secondLine to paragraph 2 of fileContents
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "="
set URLstring to last text item of secondLine
set AppleScript's text item delimiters to tid
do shell script "/usr/bin/open -a Firefox.app " & quoted form of URLstring
end open
C# app:
using System;
using System.IO;
using System.Diagnostics;
using System.Xml;
class Program {
static void Main(string[] args) {
if (args == null || args.Length == 0 || Path.GetExtension(args[0]).ToLower() != ".webloc")
return;
string url = "";
XmlTextReader reader = new XmlTextReader(args[0]);
while (reader.Read()) {
if (reader.NodeType == XmlNodeType.Element && reader.Name == "string") {
reader.Read();
url = reader.Value;
break;
}
}
// I specify Firefox because I have weird demands for my work computer.
// To have it open in your default browser, change that line to this:
// Process.Start(url);
if (!String.IsNullOrEmpty(url))
Process.Start("Firefox", url);
}
}