Tell Safari to open an html file

Ok, here’s my code:

tell application "Safari"
	open "/Users/tom/Desktop/test.html"
end tell

But when Safari opens I’m getting:

file:///:Users:tom:Desktop:test.html and its blank. How do I make Safari see the “/” characters and not substitute in “:” characters?

Model: MacBook Pro 2.33GHz
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

The open command does not expect to receive text (it expects an alias or file).

Try something like this:

tell application "Safari"
	open ("/Users/tom/Desktop/test.html" as POSIX file)
end tell

Alternatively, if you type this…

tell application "Safari"
	open POSIX file "/Users/tom/Desktop/test.html"
end tell

… It will automatically be changed to this:

tell application "Safari"
	open file "Your Hard Drive Name:Users:tom:Desktop:test.html" -- with the right drive name, of course
end tell

Thank you, those worked wonderful. That piece of my puzzle has been solved. :slight_smile: