Applescript使用Safari打开本地HTML文件

Applescript使用Safari打开本地HTML文件,safari,applescript,Safari,Applescript,我正在尝试使用Safari和以下脚本打开本地html: on run set myPath to (path to me) as text set myFolderPath to POSIX file (do shell script "dirname " & POSIX path of quoted form of myPath) & ":" as string set _thispath to myFolderPath & "data:Default.html" t

我正在尝试使用Safari和以下脚本打开本地html:

on run
set myPath to (path to me) as text
set myFolderPath to POSIX file (do shell script "dirname " & POSIX path of quoted form of myPath) & ":" as string
set _thispath to myFolderPath & "data:Default.html"

tell application "Safari"
    activate
    open (_thispath)
end tell
终点

但是,该文件正试图使用以下文件的附录打开://(额外的斜杠)
有人能解决这个问题吗?

多余的斜杠不是你的问题。首先,您希望获得“引用的posix路径表单”,而不是“引用表单的posix路径”。这给你带来了麻烦。另外,您没有正确地将内容转换为文本。无论如何,这样试试吧

set myPath to path to me
set myFolderPath to POSIX file (do shell script "dirname " & quoted form of POSIX path of myPath)
set _thispath to (myFolderPath as text) & ":data:Default.html"

tell application "Safari"
    activate
    open (_thispath)
end tell