Today in the JavaScript DOM programming Art 6th: The image Library of the improved version, according to the code in the book, Knock out to run, do not show the correct results. Add breakpoints, Debug, find: Preparegallery function is not called at all, and the Preparegallery function is bound to the Window.onload event, so carefully check the book code, found that window.onload = Preparegallery, with less parentheses behind it. After the parentheses, the result is correct. The corrected code is as follows:
1 functionAddloadevent (func) {2 varOldload =window.onload;3 //4 if(typeofWindow.onload! = ' function ') {5Alert (' Hello ');6Alerttypeof(window.onload));7Window.onload =func ();8Alert (' Hello2 ');9 }Ten Else{ OneAlert (' Hello4 '); AWindow.onload=function(){ - oldload (); - func (); the } - } -}
Therefore, functionname () is the function that is called.
A mistake in the 6th chapter of JavaScript DOM programming art