Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript from Java - document object

I am trying to invoke a java script function that creates a html div structure by using e.g.

/* ... */
document.createElement("div");
/* ... */

Unfortunately I have no window and/or document object if I'm running this script directly from Java in contrast of running it in the browser. May somebody give me a piece of advise how to use or modify the javascript code? Is there a way to create a document object by myself? Thanks a lot.

Best regards

Sascha

like image 391
user1316928 Avatar asked Jan 20 '26 11:01

user1316928


1 Answers

Rhino and Nashorn do not supply browser objects like window and document. If you want those objects, you'll have to supply them yourself. Try HTMLUnit, which provides implementations of those objects for the purposes of writing unit tests.

like image 138
David P. Caldwell Avatar answered Jan 21 '26 23:01

David P. Caldwell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!