JavaScript is a scripting language, where the browser will be executed, which is convenient for programming, but also easy to make the program too messy and fragmented.
JS from the function can be divided into two parts-the framework part and the application part, the framework part provides the JS code the organization function, including defines the global variable, the namespace method and so on, each page will have the same or the similar frame. The Application section provides the function logic of the page, the different pages will have different functions, and the Code of the different page application parts is not the same.
To the application section of the JS code a unified entry, namely:
Copy Code code as follows:
<script type= "Text/javascript" >
function init () {
//==================================================
Comments
function, engineer name, contact method of engineer, time
//=================================================
(function () {
... aaaaaaaaaaa
})();
(function () {
... bbbbbbbb
})();
}
</script>
The init () function can be called at the bottom of the page
Copy Code code as follows:
The =======init () call belongs to the frame part code ==========
<script type= "Text/javascript" >
Init ();
</script>
The =======init () call belongs to the frame part code =========
Note: The framework part of the code is mainly divided into:
1. Namespace function definition
2, function init () {} write the application part of JS
3, the Init () function call "in case the body does not write init (), but called, can be written in the following way"
Copy Code code as follows:
<script type= "..." >
if (init) {
Init ();
}
</script>