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: "Mark J. Reed" <email@hidden>
- Date: Tue, 12 Jul 2011 12:32:40 -0400
On Tue, Jul 12, 2011 at 8:29 AM, Emmanuel LEVY
<email@hidden> wrote:
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).
Not sure what you mean by '"out-of-any-handler" program', but any _javascript_ _expression_ can return a value, whether it's a function call or not. And many JS statements are in fact expressions as well. What matters is whether or not the interpreter in question chooses to expose the value through whatever means was used to invoke it; Chrome's AppleScript interface appears not to do so. (In Firefox, when you enter a _javascript_:_expression_ into the URL bar,you get a new page that contains the result of that _expression_ - unless you explicitly cast it to void - so it's easy to demonstrate that arbitrary _javascript_ can have a return value, no function call required. Try "_javascript_:1+1", for instance.)
That's why Smile, the groundbreaking - yet, free! - _javascript_-Applescript bridge, proposes in its dictionary "callJavaScriptFunction" in addition to the usual "callJavaScript".
I'm not sure what that distinction buys you. Wouldn't ' callJavaScriptFunction "someName" ' be equivalent to ' callJavaScript "someName()" ' ?
--
Mark J. Reed <
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