Writing to file to open in Safari

Is there a way to make the ‘written file’ open in Safari/IE instead of TextEdit?
I use the following script:

if my write_to_file(index_HTML, target_file, false) is false then �
	error "There was a problem creating the HTML file."


on write_to_file(this_data, target_file, append_data)
	try
		set the target_file to the target_file as text
		set the open_target_file to �
			open for access file target_file with write permission
		if append_data is false then �
			set eof of the open_target_file to 0
		write this_data to the open_target_file starting at eof
		close access the open_target_file
		return true
	on error
		try
			close access file target_file
		end try
		return false
	end try
end write_to_file

Maybe I could first copy an ‘index.html’ file to the output folder and then write to it?

Hah, yes! That’s indeed workin’ :]

How do you open the file? With the script? By double clicking the icon?

– Rob

When you create a file from scratch, using “open for access”, it automatically creates a file with creator “ttxt”, type “TEXT”. If you use an existing file (as you did), creator and type are not modified. Otherwise, you should instruct the Finder to change the creator to… “sfri” for Safari, “MSIE” for IE, or just “missing value” or “???”, which should map to the default application for files with extension “.html” (or whatever). And, if needed, also the file type (eg, “PLAY” if you created a “.m3u” to be played with QuickTime)

What script do you use to change the ‘creator’? Just curious.

tell app "Finder" to set creator type of alias "path:to:file" to "FEET"