【问题标题】:Unable to run javascript function with AppleScript无法使用 AppleScript 运行 javascript 函数
【发布时间】:2016-04-19 23:25:32
【问题描述】:

我正在尝试使用 applescript 控制网站的视频功能。该网站有一个flash 视频-jwplayer。在谷歌浏览器中,如果我输入命令,我可以暂停视频

jwplayer('player_embed').pause();

但是,如果我通过 AppleScript 发送命令,它将无法工作。

我得到的控制台错误信息如下

然后点击 VM4054:2 给我这个

【问题讨论】:

    标签: javascript applescript


    【解决方案1】:

    是否可以选择使用 Safari?这行得通...

    tell application "Safari"
        repeat with t in tabs of windows
            tell t
                if URL starts with "https://www.jwp" then
                    do JavaScript "jwplayer().pause();"
                end if
            end tell
        end repeat
    end tell
    

    【讨论】:

    • 谢谢!对不起,我完全忘了检查这个论坛。是的!这在野生动物园中确实有效。但是,我更喜欢铬。我通过使用 bettertouchtool 将“空格键”快捷方式发送到 chrome 找到了解决方法。但是,很高兴了解为什么代码在 chrome 中不起作用。非常感谢您的回答。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-15
    • 2019-07-03
    • 2013-10-12
    相关资源
    最近更新 更多