JavaScript page Auto Load event detailed

Source: Internet
Author: User

  This article is mainly on the JavaScript page automatically loading events are introduced, the need for friends can come to the reference, I hope to help you.

Method 1: The code is as follows:  window.onload=function () {   var Name=document.getelementbyid ("name"). Val ();//Load HTML, and load external all references (pictures, CSS styles, JS, etc.)}   Method 2: the. js file that needs to be introduced into jquery   code is as follows: $ (document). Ready (function () {    & nbsp    alert ("first entry case for jquery");//load HTML, do not wait, load immediately});   Method 3: (equivalent to Method 2) The code is as follows: JQuery (function () {       if ($ ("input[name= ' message ')"). Val ()!= "") &nbsp ;          alert ($ ("input[name= ' message ')"). attr ("value")); });   Method 4: (equivalent to above) the code is as follows: $ (function () {    alert ("Execute 1 when JQuery page is loaded automatically ...");  });   Method 5-1:window.onload Event loading (loading multiple functions at the same time when the page loads ...)   code as follows: <html>     <body onload= "function1 () , function2 (), Function3 () ">    </body> </html> <script >  function1 () { } Function2 () {} function3 () {} </script>   method 5-2:window.onload Event loading (loading multiple functions at the same time when page loads ...) The code is as follows: <html>     <body>     </BOdy> <html> <script>    function1 () {   }    function2 () {   } &nbs P  function3 () {   }    window.onload=function () {    function1 ();     Function2 ();     Function3 ();    } </script>  
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.