it also ties in with callback functions. Instead of using <body onload ="someFunction();"> , it says to use window.onload = someFunction; to separate js from html. My question is, why cant we just use window.onload = somefunction(); with parenthesis?
and this version :
window.onload = function(evt){
//function body
};
Is the first a call by function, second is call by reference and the third a call by function literal? What is the difference between the 3? Which to use when? The book says to use function literals when the function being called requires and argument, but why couldnt you just do document.getElementById("ID").onclick = someFunction(10);
it says to use:
document.getElementById("ID").onclick = function(evt) {
someFunction(10);
};
sorry if i am kind of unclear but i am unsure of how to explain it. I just dont get the difference between each method. Thank you for helping me
This post has been edited by Atli: 25 August 2012 - 02:50 PM
Reason for edit:: Please use [code] tags when posting code.

New Topic/Question
Reply



MultiQuote






|