In particular, there's this snippet:
-------------------
Running guest JavaScript from content
The following code in a host page:
/* host page code */
caja.initialize({ cajaServer: 'http://caja.appspot.com' });
caja.load(
undefined, // no DOM access
undefined, // no network access
function(frame) {
frame.code(
'http://example.com/default.js', // dummy URL
'application/javascript',
'(x + y);') // input source code
.api({ x: 3, y: 4 })
.run(function(result) {
alert(result);
});
});
will run the provided source, pass it the supplied values of x and y,
and alert the result of the computation, which would be the number 7.
-------------------
so it looks like what you need to do is move the source code parameter
to the end, make sure it's a valid program, and give it a dummy URL in
the first slot.
On Wed, Aug 23, 2017 at 9:55 AM, Mike Stay <[email protected]> wrote:
> There's no index.html in
> https://github.com/google/caja/tree/master/doc/cajajs
> and the developer page still points at the old site.
>
> Here's a recentish version of the API I found on archive.org.
> http://web.archive.org/web/20150428055114/http://google-caja.googlecode.com/svn/doc/cajajs/index.html
>
> On Wed, Aug 23, 2017 at 9:52 AM, Mark Miller <[email protected]> wrote:
>> What happens if you remove the "return"?
>>
>>
>> On Wed, Aug 23, 2017 at 7:23 AM, <[email protected]> wrote:
>>>
>>> I'm following the "Running Plain Javascript" example in the documentation.
>>>
>>> Instead of referencing an external URL, I'm passing in a javascript
>>> string:
>>>
>>> caja.load(undefined, undefined, function(frame) {
>>> frame.code('return function f(x) { return 1; }',
>>> 'application/javascript')
>>> .run();
>>> });
>>>
>>> I'm getting:
>>>
>>> Uncaught SyntaxError: Failed to parse program: SyntaxError: Unexpected
>>> token (1:15) in source: "return function f(x) { return 1; }" at line: -1
>>>
>>> The API reference documentation appears to be broken or moved, so I'm
>>> having trouble digging into the exact issue.
>>>
>>> Any ideas?
>>>
>>> Thanks, Justin
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "Google Caja Discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>> --
>> Cheers,
>> --MarkM
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Google Caja Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Mike Stay - [email protected]
> http://www.cs.auckland.ac.nz/~mike
> http://reperiendi.wordpress.com
--
Mike Stay - [email protected]
http://www.cs.auckland.ac.nz/~mike
http://reperiendi.wordpress.com
--
---
You received this message because you are subscribed to the Google Groups
"Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.