JavaScript Basic article 1 What is JS to establish the first JS program _ Basic Knowledge

Source: Internet
Author: User
JavaScript is an object-based and event-driven, security-based scripting language that is widely used, not just web pages, and not trapped by JSP.

Based on the object, that is, you do not need to specify the type of the variable, you give him a 3, it knows the integer, if given a value of ' 3 ', it will know is char.
Event-driven, that is, click on the event to drive it.

JavaScript Advantages: Web Interactive, simple and easy to use. JS is mainly based on client run, to a large extent, reduce the load on the server.
JavaScript is a scripting language: implemented in a program segment, combined with HTML, the Java compiler is actually the browser itself.
Security: The local hard drive cannot be accessed in an HTML page, only the network document can be deleted and modified, only through the browser to achieve information browsing or dynamic interaction.

Cross-platform: As long as there is a browser to support JS, you can run.
JavaScript is an implementation of the ECMAScript specification.

JS programming is usually in the eclipse environment, here recommend a plug-in Spket, it can smart hint code, very easy to use, download the address Spket IDE 1.6.22 according to the needs of choice, we are generally selected Spket IDE. If you are using MyEclipse, you can choose not to install it because it has a similar component in its own right.

Plug-in installation, if you are under the compression package (that is, there are two folders plugin and feature, then the contents of these two folders with the Eclipse installation directory under the same folder merged. )

If you choose an executable jar package, remember to choose the plugin option when you install it. Directory to select the installation directory for Eclipse.

Next, open Eclipse.

(not I said, eclipse icon is really difficult to see, so as the appearance of the association I actually generally use the myeclipse~) ← This sentence to see clearly, I said is the icon, is the icon! Please don't run me here. ui!

Open, you can see the Window menu under the Preference option has a spket, is we just said Plug-ins, as to how to use, will be mentioned in the future.

Next, let's build a JS-related project. File->new-> Java project I named it Testjs.

View the workspace directory of the project I'm sure you all know how to see it? In MyEclipse, the right click Project will have MyEclipse, mouse following, the right menu appears, select Open in Explorer.

Eclipse, right key point engineering, select Properties, view attributes, there are engineering directories, copy it to the window to open the line.

Then you have to set up some standard paths.

I think more and more bitter force ah, if it is myeclipse words can choose web project, just want to have ah ... 囧rz, but in order to meet the needs of most people, still have to use eclipse to learn. ).

Because we're going to build a JSP project, there are some standard paths under project to build (I copied the folders that were automatically generated after Web project created under MyEclipse):

Where the MANIFEST.MF code reads as follows:

Copy Code code as follows:

manifest-version:1.0
Class-path:

The contents of Web.xml are as follows:
Copy Code code as follows:

<?xml version= "1.0" encoding= "UTF-8"?>
<web-app version= "2.5"
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 ">
<welcome-file-list>
<welcome-file>main.html</welcome-file>
</welcome-file-list>
</web-app>

Create a new file (new->file main.html suffix is not small), main.html code as follows:
Copy Code code as follows:

<title> (* ̄▽ ̄) </title>

<body>
This is my page. <br>
</body>

Next we're going to be editing this thing to enjoy the thrill that JS brings to us. ~!

First of all, in order to code specifications, I would suggest that the contents of JS are stored in the new. js file, one can achieve code sharing, but also optimistic about editing.

As a type a blood micro-obsessive-compulsive disorder, I can never write if I see the code at sixes and sevens.

So, here we first click on the Webroot directory right-click, select new->folder+ (not to say that the establishment of JS files, Soul light!) =.= Don't worry, we put the JS file together this is more good-looking AH ~

Create a new folder called JS. Then right click on this folder, New->file casually write a name, remember to add a suffix, I named it output.js.

Before we edit the JS file, we demonstrate the use of spket, which can help us build code templates, as follows:

In this way, we have established a name called Func template, open the JS file, input func, press the alt+/hint to find the template, enter, there are patterns in the code we define:

So we have a function in the JS file ~!

So we can understand it ~ spket may be used to customize the hint, at the same time it has its own JS template, preference the spket under the various things, it is almost familiar.

However, we usually import a ExtJS package, will be useful in the future, download the address Senta

The method of loading in Spket is:

Next in the last step is add file, and then load the things just downloaded into the line.

Finally, to come, we refer to the JS file in HTML, even if the success of today ヘ ( ̄▽ ̄ヘ):

In Main.html, write the following code:

Copy Code code as follows:

<title>O.O</title>
<script type= "Text/javascript" src= "Js/output.js" ></script>
<script type= "Text/javascript" >
Testoutput ("dumpling");/Use function
</script>

<body>
This is the My JSP page. <br>
</body>

Referencing files using src= "xxxxx.jsp"
Next, find the engineering directory, double-click the HTML file to see the effect of it ~

The above is the test information in different browsers, very compatible with it ~

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.