JS在新的safari窗口中提示打开?

时间:2013-12-15 23:30:49

标签: javascript safari applescript

以下脚本在新选项卡中打开带有文本的JS提示,我希望它只在新窗口中执行相同的操作。为了达到这个目的,我需要改变什么?

    set searchTerm to “ebay”

    do shell script "/usr/bin/osascript -e 'delay 1' -e 'tell application \"System         Events\" to keystroke \"" & searchTerm & space & "\"' > /dev/null 2>&1 &"

    tell application "Safari"
        activate
        set newTab to make new tab in window 1
        set current tab of window 1 to newTab
        do JavaScript         "javascript:Qr=prompt('','');if(Qr)location.href='http://www.yubnub.org/parser/parse?        command='+escape(Qr)" in current tab of first window
    end tell

2 个答案:

答案 0 :(得分:1)

您需要做的就是制作一份新文件

set searchTerm to "ebay"

do shell script "/usr/bin/osascript -e 'delay 1' -e 'tell application \"System         Events\" to keystroke \"" & searchTerm & space & "\"' > /dev/null 2>&1 &"

tell application "Safari"
    activate
    set thisWindow to make new document
    tell thisWindow to do JavaScript "javascript:Qr=prompt('','');if(Qr)location.href='http://www.yubnub.org/parser/parse?        command='+escape(Qr)"

end tell

答案 1 :(得分:-1)

作者无法做的任何事情都可以选择在新窗口中打开而不是新标签。