I was just experimenting with some javascript code on JsFiddle and then I was completely blank being not able to understand a code. JsFiddle link is http://jsfiddle.net/K3w7c/
Question:What does following mean?
window.onload=function(){
var clicked = function(){
alert('i am hit');
}
}
and how to do I call the "clicked" function from a code something like
<a href="#" onclick="clicked();">Hit me</a>
please note: I know if the function definition was outside the window.onload
then it will work but I am really not able to understand the use case when would I have a function declaration inside window.onload
and if there is such a declaration then how do I call it.
thanks.