node.js - jsdom: Run a page's javascript functions -
this question has answer here:
i've been messing around jsdom , can't figure out how run functions html page. example, i've got simple page this:
<html> <body> hello </body> <script> function test() { document.write("bye bye") } </script> </html>
and i'd execute test
function jsdom. how go doing this? i've tried calling function, node complains doesn't exist.
jsdom.env({ url : "http://localhost:8000/test.html", features : { fetchexternalresources : ['script'], processexternalresources : ['script'] }, done : function (error, window) { test(); // i'd this. console.log(window.document.innerhtml); } });
well apparently correct way window.test()
, , appropriate features:
jsdom.env({ url : "http://localhost:8000/test.html", features : { fetchexternalresources : ['script'], processexternalresources : ['script'] }, done : function (error, window) { window.test(); console.log(window.document.innerhtml); } });
Comments
Post a Comment