2013-07-20 39 views
0

我試圖運行下面的腳本:AppleScript的打開與osescript和特定的URL野生動物園

on run proUrl 
    tell application "Safari" 
     make new document with properties {URL:proUrl} 
    end tell 
end run 

這是我嘗試運行它:osascript script.scpt http://google.com
我收到以下錯誤:
script.scpt: execution error: Safari got an error: AppleEvent handler failed. (-10000)
萬一我substitue的proUrl變量"http://google.com"然後它工作。

我該如何解決這個問題?

回答

1

proUrl是一個項目列表,即使只有一個項目發送給蘋果。所以實際的網址是「proURL的第1項」。以下是我會寫腳本...

on run proUrlList 
    open location (item 1 of proUrlList) 
end run 
1

要在命令行默認瀏覽器中打開一個網址,只需使用open

open http://google.com 

更多見man open

相關問題