Re: Google Chrome: Set variable to result of JavaScript
Re: Google Chrome: Set variable to result of JavaScript
- Subject: Re: Google Chrome: Set variable to result of JavaScript
- From: Emmanuel LEVY <email@hidden>
- Date: Tue, 12 Jul 2011 14:29:28 +0200
I think it's not Chrome, it's javascript. Only functions can return
values, not the "out-of-any-handler" program. Check ECMA's specs (I
didn't).
That's why Smile, the groundbreaking - yet, free! - Javascript-
Applescript bridge, proposes in its dictionary
"callJavaScriptFunction" in addition to the usual "callJavaScript".
Emmanuel
On Jul 11, 2011, at 11:05 PM, Christopher Stone wrote:
On Jul 11, 2011, at 15:28, Nathan Greenstein wrote:
I've been trying to get Chrome to do some JavaScript in a tab, and
set the result of that to an AppleScript variable.
______________________________________________________________________
Hey Nathan,
Part of your problem is that Chrome does not yet support getting a
result from an executed javascript. The only way I know of at
present is to set the title from js and pull that into Applescript,
although there's probably a spiffier method that doesn't have a
character limit.
Please take the time to complain about this to Google: chrome://
bugreport/#4
tell application "Google Chrome"
tell front window
tell active tab
execute javascript "document.title = 'some result';"
set x to title
end tell
end tell
end tell
I'm very pleased to see them starting to support Applescript, but
they've got a little way to go yet.
--
Best Regards,
Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden