Calling an AJAX function declared as a VAR, using Applescript
I am trying to run a javascript code inside a page using Applescript.
The AJAX function was declared in 开发者_StackOverflowjavascript using something like this
var myFunction = function () {
// bla bla... here goes the code...
}
I have tried this in Applescript:
do JavaScript "document.myFunction()"
but the code is not running.
any clues? thanks.
Global variables are created as properties of the global object (window
, for web browsers). Thus window.myFunction
would be the proper reference. However, you don't need to specify the global object.
The key is that you must specify in AppleScript the target tab or document. For example:
tell application "Safari"
do JavaScript "myFunction()" in current tab of window 1
end tell
精彩评论