A mistake in the 6th chapter of JavaScript DOM programming art

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.