0

我正在尝试使用带有以下脚本的 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:/// (一个额外的斜杠)的附录打开任何人对此有任何解决方案吗?

4

1 回答 1

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
于 2012-07-11T19:19:07.757 回答