Bentley4 Bentley4 - 1 year ago 98
Javascript Question

How do I output something in Rhino?

I'm looking for the javascript equivalent of Python2.x's

print "hi"
I'm working with the Rhino javascript interpreter in the ubuntu terminal.
When I type:


I get the error that 'document' is not defined.

Answer Source

JavaScript doesn't have any built in methods to provide output. Scripts have to depend on features provided by the host environment for that.

document is an object that is available in web browsers, but not in Rhino. Even if it was available, document.write is a function. You use () to call a function, not {}.

Rhino provides a print function.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download