john stoe john stoe - 1 year ago 88
HTML Question

Call a JavaScript function before declaration

I have this function inside


function testing(){

And then a basic HTML page.

Is it possible to call the function before being declared and add this to the page?


Because if I include the
at the bottom of the page, it’s not working. Is there a way to make it work (with a JavaScript file being included at the bottom of the HTML page)?

Answer Source

put your testing() function call inside window.onload callback, like this,

window.onload = function(){ testing(); }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download