Many methods to implement a JS function _jsp programming when the JSP page completes full load

Source: Internet
Author: User
Tags script tag
Method 1:The following procedure executes the Opentheindexpage () method when the page is fully loaded
Copy Code code as follows:

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>telecommunications Data Collection system</title>
<script type= "Text/javascript" src= "<%=contextpath%>/js/baseframe.js" ></script>
<script type= "Text/javascript" src= "<%=contextpath%>/js/cookies.js" ></script>
<script type= "Text/javascript" src= "<%=contextpath%>/js/tag/tag.js" ></script>
<script language= "javascript" for= "window" event= "onload" >
function Opentheindexpage () {
Openmyuriwithcid (True, ' root ', ' IDX ', ' iframe/dispatch.jsp?url=tdc/zhk/impctrlobjinf/index/index.jsp ', ' home ',
' Top.tagmenu ', ' top.maintop ', true,
' System/accesspaths.do?currentmodulecode=idx ',
' MainMenu ', true);
};
if (document.readystate== "complete") {
Opentheindexpage ();
}
</script>
<body>
</body>

Method 2: Can be the following, but the effect is not as good as Method 1.
Copy Code code as follows:

<body onload= "function name ()" > </body >
<script>window.onload=function name </script>
<script language= "javascript" for= "window" event= "onload" >function name (); </script>

The second one can only write a function, and can not give variables, the most useful is the last one, you can write independently, how the writing is OK.

Method 3: <body onload= "xxx ()" > </body> xxx () for the function you want to perform

Method 4: Add defer to the script tag
namely <script defer= "defer" language= "JavaScript" >
or <script defer language= "JavaScript" >
Run the script after the entire page has been loaded. (No effect)
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.