2012-07-11 74 views
0

我試圖打開使用Safari與下面的腳本本地HTML:AppleScript的打開本地的HTML文件的Safari

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 

運行結束

但是,該文件正在試圖與apendix打開的文件:///(一個額外的斜線) 任何人有任何解決方案?

+0

您的HTML是着火。 – TheZ 2012-07-11 17:18:28

回答

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