我正在尝试从Safari获取网址,关闭标签并在Chrome中打开它(TUAW Post)但是我一直收到错误:
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 :(得分:7)
对我有用......
tell application "Safari"
set theURL to URL of current tab of window 1
end tell
您必须显示更多代码,因为错误是由其他内容引起的。让我问你这个,你有另一个tell块里面的应用程序Safari声明吗?也许它是在google Chrome代码块中?如果有,请将其删除。
答案 1 :(得分: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