I'm looking at trying to make JS calls from within Processing. I've managed to get the Javascript library that comes with Processing working, but I've only been able to get alert calls to work, while I'd ideally like to be able to call entire functions.
If I place the function verbatim inside the eval(), it breaks as soon as it encounters a new line. If I place the entire function onto a single line by eliminating the line breaks, it crashes upon encountering a colon.
If anyone could give me some pointers, that would be great. Alternatively, if anyone has a way of reading cookies from a Processing applet, that would be great too! (I could only find reference to a single cookie library for Processing, but it looks like it's long since been taken offline)
Thanks all!
This is the test code I'm working with:
import netscape.javascript.*;
void setup() {}
void draw() {}
void mousePressed() {
try {
JSObject.getWindow(this).eval( "alert(\"This is a JS test.\")" );
}
catch (JSException e) {
e.printStackTrace();
}
}
This is the JS function I'd like to call upon mousePressed:
I'm writing a sketch I intend to compile into an applet.
I need to find the IP address of the computer currently running the sketch.
I've tried using client.ip(), but I don't think that's really what I'm after.
Has anyone had any experience or (even better) success with this sort of thing?