Evaluate JavaScript within a HTML with Java -


I have to get the HTML output generated from javascript in the HTML string given in Java.

First of all, I do not know how to set full HTML and javascript in code I have seen that all, I can give Java some small javascript, add some parameters and get some output I am Is there a way to set an HTML-string as a reference?

Example (taken from other threads):

  & lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Trial & lt; / Title & gt; & Lt; Body & gt; & Lt; / Body & gt; & Lt; Div & gt; Welcome to & lt; / Div & gt; & Lt; Style type = "text / css" & gt; .title {color: red} & lt; / Style & gt; & Lt; Script type = "text / javascript" & gt; Var i = 0; (I = 0; i <5; i ++) {document.writeln ("& lt; div class = 'title' & gt;" + i + "") ; } & Lt; / Script & gt; & Lt; / Html & gt;  

I want to pass this HTML code in Javascript context and call the function (Actually does not have a function, but I know how to call the Javascript function) < / P>

Then, rendering in the browser will return this HTML to you:

  & lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Trial & lt; / Title & gt; & Lt; Body & gt; & Lt; / Body & gt; & Lt; Div & gt; Welcome to & lt; / Div & gt; & Lt; Style type = "text / css" & gt; .title {color: red} & lt; / Style & gt; & Lt; Script type = "text / javascript" & gt; Var i = 0; (I = 0; i <5; i ++) {document.writeln ("& lt; div class = 'title' & gt;" + i + "") ; } & Lt; / Script & gt; & Lt; Div class = "title" & gt; 0 & lt; / Div & gt; & Lt; Div class = "title" & gt; 1 & lt; / Div & gt; & Lt; Div class = "title" & gt; 2 & lt; / Div & gt; & Lt; Div class = "title" & gt; 3 & lt; / Div & gt; & Lt; Div class = "title" & gt; 4 & lt; / Div & gt; & Lt; / Html & gt;  

So, basic output on javascripting manger is simple:

  welcome 0 1 2 3 4  

I None of these elements wants to render, I'm interested only in getting the HTML output. I'm not sure how to do this work.

I want to keep it simple, no framework wants, just a simple mechanic passing HTML code and javafunctions on JavaScript, evaluating it and receiving HTML back, like a browser more The HTML code gets back (usually). Checked out the new National JavaScript Engine in Java 8?

>

I have actually used it so far, so I'm sure It is not that you can just pass it html strings or you will need to separate JS and HTML, but it is worth taking a look.

Here's a basic tutorial:

If not, always have the FontMJs that you can use to execute javascript. Here are some examples:

It seems that some useful functions such as page loading and code evaluate that you may be able to use it.


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -