Example:
<script type="text/javascript">
function test() {
console.log("Hello world");
}
</script>
How would I call test()
?
Edit: I didn't explain this correctly.
I am using the request module of node.js to load an external html file that contains javascript functions:
request.get(options, function (error, response, body) {
if (error && response.statusCode !== 200) {
}
else {
jsdom.env({
html: body,
scripts: ["../jquery-1.6.4.min.js"]
}, function (err, window) {
var $ = window.jQuery;
I'm just looking for the syntax to call a function in 'body'.