HI,
I have some trouble to call function javascript in applescript
my javascript function is
function playalbum(){
alert (“some text”);
}
----- applescript ------
tell application “Google Chrome”
activate
open location “file:///Users/jean-marcplanas/Desktop/d.html”
delay 6
execute javascript “function playalbum();”
delay 1
end tell
google chrome is ok and load page.
but applescript return missing value
result :
tell application “Google Chrome”
activate
open location “file:///Users/jean-marcplanas/Desktop/d.html”
execute current application javascript “function playalbum();”
–> missing value
end tell
AppleScript to JavaScript to Chrome? Oh dear lord.
Anyhow, the answer to your question is the way you’re executing the JavaScript.
You define functions with the function verb, you do not use it to execute them.
Try using execute current application javascript "playalbum();"
instead.
not works
error : impossible to execute number -1708
tell application “AppleScript Editor”
«event CrSuExJa» current application given «class JvSc»:“playalbum()”
–> error number -1708
if my web page I have a button id=“monalbum” with event OnClick=“playalbum()”
When i click on this button it’s works, I see alert message test of the function playalbum.
so i did many test to execute function but nothing works.
--execute javascript "document.getElementsByid('monalbum').click()"
--execute javascript "function playalbum();"
--tell active tab of front window to execute javascript "playalbum(){alert('sdf')}"
--execute javascript "function playalbum();"
--execute current application javascript "playalbum();"
-- execute javascript "function playalbum()"