Subj : Newbie: execute javaScript-code To : netscape.public.mozilla.jseng From : jupp4711 Date : Tue Jul 27 2004 11:54 am hello rhino-experts, i'm still newbie with rhino and this might be a simple question: i have a quit long javaScript-code stored in an Java-string and want to execute it. as result i need the html-code thats produced by the js-code. here is my java-method so far: ****************************** public void runScript(String s) { // throws JavaScriptException // Creates and enters a Context. The Context stores information // about the execution environment of a script. Context cx = Context.enter(); try { // Initialize the standard objects (Object, Function, etc.) // This must be done before scripts can be executed. Returns // a scope object that we use in later calls. Scriptable scope = cx.initStandardObjects(); // Collect the arguments into a single string. // String s = ""; // for (int i=0; i < args.length; i++) { // s += args[i]; // } // Now evaluate the string we've colected. Object result = cx.evaluateString(scope, s, "", 1, null); // Convert the result to a string and print it. System.out.println(Context.toString(result)); //s); // }catch (Exception e){ // SbErrorReporter serr System.out.println("runScript:catch: " + e.toString()); } finally { // Exit from the context. Context.exit(); } } ****************************** first question: is this the way to execute js? will i get my html with this method? by now the console return this: runScript:catch: ReferenceError: "window" is not defined. (; line 57) i need to jump over such errors, because i have no control over the stored js. second question: how can rhino ignore such js-errors? thanks for helping juppi .