Can I create a 'window' object for javascript running in the Java6 Rhino Script Engine

后端 未结 2 1487
悲哀的现实
悲哀的现实 2021-01-05 17:01
  • I want to run some Javascript on my Java6 server - i.e. using the javax.script API, specifically the Rhino Script Engine. (Although another solution would be acceptabl
2条回答
  •  清酒与你
    2021-01-05 17:30

    var window = {}
    var document = {}
    

    ... of course, they won't do a lot of good unless you populate them with the properties that the script is trying to access.

    You can't just populate them with the standard browser APIs - most of them don't make sense outside the context of the browser.

提交回复
热议问题