2011-08-28 139 views
1

我想從Safari瀏覽器的URL,關閉選項卡,並在Chrome中打開它(TUAW Post)獲取URL,但我不斷收到錯誤:的AppleScript從Safari瀏覽器

error "Safari got an error: Can’t get current tab." number -1728 from current tab 

從代碼行:

set theURL to URL of current tab of window 1 

有什麼建議嗎?

所有代碼:

property theURL : "" 

tell application "Safari" 

    set t set theURL to URL of current tab of window 1 
    close current tab 

end tell 

tell application "Google Chrome" 

    set URL of active tab of window 1 to theURL 

    activate 

end tell 
+0

任何機會,你的Safari窗口全屏? – duozmo

+0

不記得了。但對我的問題的解決方案進一步張貼在頁面下方 – Runar

+0

但是在解決方案中,給你帶來麻煩的代碼行並沒有改變。我認爲這是一個零星的錯誤,只有當Safari全屏時纔會發生。 – duozmo

回答

5

它爲我...

tell application "Safari" 
    set theURL to URL of current tab of window 1 
end tell 

你必須表現出更多的代碼,因爲錯誤是由別的東西造成的。讓我問你這個問題,你有告訴應用Safari語句裏面的另一個告訴塊嗎?也許它是在告訴谷歌Chrome代碼塊?如果這樣刪除它。

+0

'財產theURL:「」 告訴應用程序「野生動物園」 \t 集theURL於前文件的URL作爲字符串 \t關閉當前標籤頁 \t 端告訴 告訴應用程序「谷歌瀏覽器」的 \t \t集網址窗口1至theURL \t \t 活動選項卡激活 \t 端tell' – Runar

+0

更新後。它現在包含所有的代碼 – Runar

+0

好吧,現在我看到你的錯誤。這是在「關閉」線。讓它這個...關閉窗口1的當前標籤。 – regulus6633

0

非常感謝你們!這是最終的代碼。

property theURL : "" 

tell application "Safari" 

    set theURL to URL of current tab of window 1 

end tell 

tell application "Google Chrome" 

    tell window 1 
     make new tab with properties {URL:theURL} 
    end tell 

    activate 

end tell