An event is an action performed by a user or a browser. For example, click and mouseover are all the names of events. The corresponding function of an event is called an event handler (or an event listener ). There are several ways to specify a
This means that appropriate events will bubble up and the browser will execute the assigned event handler. This capability is very useful when testing web applications. It provides methods in the DOM Level 3 specification to simulate specific events,
1. Window position
The following figure shows the position of the browser window from the left and top of the screen.
Copy codeThe Code is as follows: var leftPos = (typeof window. screenLeft = "number ")? Window. screenLeft: window. screenX; //
The html example to be used in this section
Copy codeThe Code is as follows:
Project 1
Project 2
Project 3
1. Create an element nodeThe document. createElement () method is used to create an element. It accepts a parameter, that is, the tag
1. function internal attribute arguments
Arguments is used to save the function parameters. arguments. callee points to a function with an arguments object.
Copy codeThe Code is as follows: // factorial
Function factorial (num ){
If (num Return 1;
}
1. prototype chain
// Rarely used separately
Copy codeThe Code is as follows: View Code
// Defines the SuperClass class, which has an attribute property and a method getSuperValue
Function SuperClass (){
This. property = true;
}
SuperClass.
The toFixed () method specifies the number of decimal places.
The toExponential () method uses scientific notation to represent the number of decimal places. The parameter specifies the number of decimal places.
The toPrecision () method
1. typeof OPERATOR: used to detect the Data Type of a given variable
Copy codeThe Code is as follows: var message = "some string ";
Alert (typeof message); // "string"
Alert (typeof (message); // "string"
Alert (typeof 100); // "number"
The typeof
The Code is as follows:
Copy codeThe Code is as follows :/**
* Countdown
*
* @ Author WadeYu
* @ Date
* @ Copyright boyaa.com
*/
Var TimeCountDown = function (initTime ){
Var day = 0;
Var hour = 0;
Var minute = 0;
Var second = 0;
Var timerId =
Previous approach-I guess most people use it
For example, the following code is taken from a piece of js Code on the Sina homepage. This method is also used by most people.
What did you do after reading the above Code? You may change the form
As follows:
Copy codeThe Code is as follows: var person = new Object ();
Person. name = "Nicolas ";
Person. age = "29"
Person. job = "Software Engineer ";
Person. sayName = function (){Alert (this. name );};
Person. sayName (); in the
Console. log was originally a "patent" of Firefox, and strictly said it was a "trick" for debugging unique to Firefox after Firebugs was installed ".
This trick is learned by IE8, but it is more difficult to use than Firebugs. The console. log can
Since I have been reading javascript recently, I will briefly introduce some usage of the three of them in javascript.
Break statement:The break statement causes the running program to immediately exit the loop contained in the innermost layer or
I. Naming
1. You should give the variables and functions a specific name.
2. Non-constructor uses the camper name method and adopts the dynamic object structure as much as possible to be different from the variable name, such as getName or IsFull.
Create a drag object when mousedown, and release the object when mouseup. The principle is very simple.
Simple drag implementation code:Xmlns = "http://www.w3.org/1999/xhtml">
Drag me
The JQury framework is definitely the first choice for page development. The code is short and powerful. The disadvantage is that the object-oriented feature is insufficient. Fortunately, there are many plug-ins! As for Ext, it is a huge object. It
Write a small example:
Step 1: create a "Mobile Phone type"Copy codeCode: var MobilePhone = (function (){............})()
Step 2: Consider the private attributes of these classes. Here I want to define the number of mobile phones that come out of
First look at the layer to be dragged (simulate the window.
Drag effect: Click the left mouse button on the title bar above the window and move the mouse at the same time.Window:
Copy codeThe Code is as follows:
Some preparations:To allow the
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