I currently set up EnvJS on my system (installed from here). My end goal is to load a page let it's javascript process for a few seconds, and then read the dom to get the information of interest. However I can not get setTimeout() to work to save my life (Or JQuery for that matter).
I have a php script that starts the process:
...
$ENVJS_PATH = "/var/www/project/src/envjs";
$RHINO_JAR = "rhino/js.jar";
$INIT_SCRIPT = "init.js";
$output = shell_exec("java -jar $ENVJS_PATH/$RHINO_JAR -opt -1 $ENVJS_PATH/$INIT_SCRIPT");
echo "Response from javascript:<br/> $output";
...
the init.js file looks like:
load('/var/www/project/src/envjs/dist/env.rhino.js');
print("Loaded env.rhino.js<br/>");
// temporarily commented out
//var url = "http://www.ken-soft.com";
//window.location = url;
//print("<br/>Loaded "+url+"<br/>");
// Problem starts here
var runAfterPause=function() {
print("got here..."); // never gets called
print(document.getElementById('some_id').innerHTML);
}
setTimeout(runAfterPause, 3000); //wait three seconds before continuing
// i have also tried setTimeout("runAfterPause()", 3000);
print("<br/>End<br/>");
Any knowledge on this would be much appreciated. Thanks.