How to execute a Javascript function in an HTML page, in a browser, from a Java class on my server? -


  <script type="text/javascript">     function start() {         window['progress'] = setinterval(function() {             var pbclient = pf('pbclient'),             oldvalue = pbclient.getvalue(),             newvalue = oldvalue + 10;             pbclient.setvalue(pbclient.getvalue() + 10);              if(newvalue === 100) {                 clearinterval(window['progress']);             }         }, 100);     }   </script> 

i want call function in java class.actually problem progress bar in dialog.and want go xhtml page after progress bar

to call external javascript functions can use scriptengine.eval(java.io.reader) , here documentation

scriptenginemanager manager = new scriptenginemanager(); scriptengine scr_engine = manager.getenginebyname("javascript"); // read script file engine.eval(files.newbufferedreader(paths.get("full path of js file"), standardcharsets.utf_8)); invocable invvoc = (invocable) scr_engine; // call js function script file invvoc .invokefunction("yourfunctionname", "param"); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -