1

I have a JavaScript library which generate html depending on parameters passed to the library. e.g. The library has a method which accepts id of an html button and the method then wraps html button with html div (and some inline css) to make it look good. The method returns html string representation of the button.

Is it possible to use this JS library with Rhino and call the method by passing some id (which should actually be an id of a button in html page) and get html string representation of the button?

Thanks in advance

2 Answers 2

2

Yes, it is possible to load JS libraries into Rhino and use them. You could then either specify the window.location to the html page you or create an element and use innerHTML to put it into the DOM (if you have the HTML as a String). If you are just trying grab a button by its id attribute then you might considering just using document.getElementById and not loading your library. Here is a blog article that talks about loading JS libs like jQuery, Prototype and Mochikit into Rhino:

http://ejohn.org/blog/bringing-the-browser-to-the-server/

Sign up to request clarification or add additional context in comments.

1 Comment

@Chir, did you ever succeed with this?
0

As far as I understand, the Rhino library, when called from within a Java program, has no access on its surrounding HTML, so you can't use a button's ID from the web page. Of course, you could create the HTML code from the scratch, if your library supports this.

If your button is embedded in the HTML page surrounding your applet, you would better use the Javascript bridge to call the browser's Javascript engine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.