Javascript basics 1 What is js the first javascript Program-basics-js tutorial

Source: Internet
Author: User
Javascript is the basis of many things, such as jsp and ajax. If this is not the case, it will be more difficult to learn these things, to lay a solid economic foundation for future learning javascript is an object-based and event-driven, secure scripting language that is widely used, not just webpage, but not trapped by jsp.

Based on the object, you do not need to specify the type of the variable. You can give it a value of 3, which knows it is an integer. If you assign a value of '3', it knows it is a char.
Event-driven, that is, click, and other events to drive.

Advantages of javascript: Web pages are highly interactive and easy to use. Js is mainly run based on the client, greatly reducing the load on the server.
Javascript is a scripting language: it is implemented using a program segment. It is combined with HTML. the java compiler is actually the browser itself.
Security: you cannot access a local hard disk on an HTML page. You can only delete or modify Network documents. You can only use a browser to browse information or perform dynamic interaction.

Cross-platform: any browser that supports js can run.
Javascript is an implementation of ECMAScript specifications.

Js programming is usually in the eclipse environment. A plug-in is recommended here.SpketIt can intelligently prompt the code, which is very easy to use. spket IDE 1.6.22 can be selected as needed. We generally choose Spket IDE. If myeclipse is used, you can choose not to install it because it includes similar components.

For plug-in installation, if you have a compressed package (that is, there are two folders plugin and feature, you can merge the contents of these two folders with the same folders under the eclipse installation directory .)

If you select an executable jar package, remember to select the plugin option during installation. Select the installation directory of eclipse.

Next, open eclipse ~

(I am not saying that the eclipse icon is really ugly, so as the appearance Association, I generally use myeclipse ~) The remark is clear. I am talking about icons and icons! Please do not run the UI here!

After opening, we can see that spket is included in the preference option in the window menu, which is the plug-in we just mentioned. As for how to use it, we will mention it in the future.

Next, let's create a js-related project. File-> new-> java project I named it testJs.

I believe everyone knows how to view the workspace directory of the project? In myeclipse, If you right-click the project, myeclipse will be displayed, followed by the mouse. The menu appears on the right, and select open in explorer.

In eclipse, right-click the project and select properties to view the properties. There is a project directory in it. Just copy it to the window and open it.

Then we need to create some standard paths.

(The more I think about it, the harder I think. If myeclipse is used, you can select a web project. All you want will be available... except rz, but to meet the needs of most people, we still need to use eclipse to learn .).

Because we want to create a jsp project, there must be some standard paths under the project, create a folder by referring to the image below (I copied the folder automatically generated after the web project created under myeclipse ):

The MANIFEST. MF code is as follows:

The Code is as follows:


Manifest-Version: 1.0
Class-Path:


The content of web. xml is as follows:

The Code is as follows:



Xmlns = "http://java.sun.com/xml/ns/javaee"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee
Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd>

Main.html



Create a New File (New-> File main.html suffix. The main.html code is as follows:

The Code is as follows:




(*  ̄)



This is my page.




Next, we need to edit this stuff to enjoy the pleasure of js ~!

First of all, for the sake of code specifications, I suggest you store all js content in the newly created. js file so that you can share the code and enjoy editing.

As a type-A micro-obsessive-compulsive disorder, if I see a mess of code, it cannot be written.

Therefore, right-click the WebRoot directory and choose New> Folder + (not to create a js file !) =. = Don't worry. It looks nice to put the js files together ~

Create a folder named js. Right-click the folder and choose new> file to enter a name. Remember to add a suffix and name it output. js.

Before editing the js file, we will demonstrate the usage of spket. It helps us to create a code template. The process is as follows:

In this way, we create a template named func, open the js file, enter func, press ALT +/to find the template, and press Enter, the code defined in pattern appears:

In this way, we have a function in the js file ~!

So that everyone can understand it ~ Spket can use a custom prompt. At the same time, it already comes with a js template. You can get familiar with all the things in spket under preference.

However, we generally import an extjs package, which will certainly be useful in the future, senta

The loading method in spket is:

Next, the last step is to add file and load the downloaded content.

Finally, let's refer to the js file in html. Today, even if it is a big success, we can see the following ):

In main.html, write the following code:

The Code is as follows:




O. O

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.