我正在尝试使用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
结束
但是,该文件试图使用file:///(一个额外的斜杠)的附录打开 有人对此有任何解决方案吗?
答案 0 :(得分:0)
额外的斜线不是你的问题。首先,您希望得到“引用形式的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