Home > Web Front-end > JS Tutorial > Set a unified entrance for the js code in the application part_javascript skills

Set a unified entrance for the js code in the application part_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:44:42
Original
1109 people have browsed it

JavaScript is a scripting language that will be executed wherever the browser downloads it. This feature will provide convenience for programming, but it can also easily make the program too messy and fragmented.

JS can be functionally divided into two parts - the framework part and the application part. The framework part provides the organization of js code, including defining global variables, namespace methods, etc., each page will Have the same or similar framework. The application part provides page function logic. Different pages will have different functions, and the codes in the application part of different pages are also different.

Give a unified entrance to the js code of the application part, that is:

Copy the code The code is as follows:



Call the init() function at the bottom of the page
Copy code The code is as follows:

//=======init() calls the code that belongs to the framework ==========



//========init() call belongs to Framework code ========

Note: The framework code is mainly divided into:

1. Namespace function definition

2. function init(){ } Write the js of the application part inside it

3. Calling the init() function [In case init() is not written in the body, but it is called, the following writing method can be used]
Copy code The code is as follows:


Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template