Subj : Re: Rhino and outputting browser javascript To : netscape.public.mozilla.jseng From : block111 Date : Thu Oct 21 2004 12:50 pm cool_screen_name90001@yahoo.com (CSN) wrote in message news:<5872245.0410201427.1ff05e5e@posting.google.com>... > Is it possible to output javascript's output from scripts that appear > in browsers? For example, I have a script that has a bunch of > document.write('...') calls. When trying to run it via the command > line I get this error: > > java -classpath rhino/js.jar jsfile > > uncaught JavaScript exception: ReferenceError: "document" is not > defined > > I'm basically interested in outputting the results of javascript, as > they would be seen in browsers (the HTML). > > Thanks, > CSN document object is not javascript built-in object - it's provided by the browser. In order for the scripts to be able to work without modifications you should create object document with public method write. From there you can do whatever you want with the output. For example, if(typeof(document) == 'undefined'){ document = new Object; document.write=function(s){ print(s); } } or something like this before any script that uses document.write may solve the problem .