CopyCode The Code is as follows: // obtain the X coordinate of the element.
Function pagex (ELEM ){
Return ELEM. offsetparent? (ELEM. offsetleft + pagex (ELEM. offsetparent): ELEM. offsetleft;
}
// Obtain the Y coordinate of the element
Function
The space is fully displaced by the absolute position of CSS. Before getting started, let's practice the recursive usage of setTimeout (used to simulate setinterval ).
CopyCode The Code is as follows: function text (EL ){
VaR node = (typeof El =
Then the function is split into two parts and stored in the object. One is the function name (key), the other is the function body (value ), this in a function generally points to the object where the function is located. However, this is normal.
In JavaScript, the execution sequence of mousedown, mouseup, and click is left to right. More importantly, once the mousedown event is activated, normal situation (the method not bound in the mousedown event uses a similar alert method, because the
Let's take a look at this section.
Code :
Copy code The Code is as follows:
A very simple piece of code. Let's see what new has done? We can split the new process into the following three steps:
var P = {}; that is, initialize an object p.
Code As follows:
Copy code The Code is as follows:
But we cannot reuse this object. How do we use this object as a prototype?
First of all, it is impossible to have a constructor in a json object. Let's make a simple "Factory" and write a method
Offsettop can be used to obtain the position of the HTML element from the top or the outer element. style. Top is also supported. The difference between the two is:
1. offsettop returns numbers, while style. Top returns strings. In addition to
However, in some large web interaction projects today, such as large webgame projects, the influence of JavaScript event bubbling is worth noting. This article uses a simple example to explain the Javascript event bubbling and precautions.
If you
Today's JavaScript is no longer a fancy script used as a toy to run on a webpage. Javascript has been gradually standardized, as a real
Programming Language It is widely used in Web development. As a result, more and more people begin to
Firefox also supports the innertext method of IE.
CopyCode The Code is as follows: function isie (){
If (window. Navigator. useragent. tolowercase (). indexof ("MSIE")> = 1)
Return true;
Else
Return false;
}
If (! Isie () {// Firefox innertext
Although the key of this set can only be of the string type, unlike various collection classes in Java that can use various objects as keys, it is enough to implement general client JS functions. Similarly, because all internal JS objects inherit
Let's take a look at the official explanation:
Call Method
See
Applied to: Function objects
Requirements
Release 5.5
Call a method of one object to replace the current object with another object.
Call ([thisobj [, arg1 [, arg2 [, [,.
I. Factory method
Self-understanding: To create instances with many objects, these instances have the same attributes but different attribute values. In this case, you need to create a factory function ).
Factory function: Creates and returns
1. Use hidden IFRAME to load ad pages.
CopyCode The Code is as follows:
Using the above Code will cause IFRAME to load ad pages. If the page is too large, the speed will be very slow,You can use ajax to implement refreshing loads.Copy
Typeof is used to obtain the type of a variable. Generally, typeof can only return the following results: Number, Boolean, String, function, object, undefined. We can use typeof to obtain whether a variable exists, as shown in figure
If (typeof!
CodeThere is only one type of function.
Undefined: Undefined. We can also call it nonexistent. typeof (undefined) = undefined.
Null: null. Undefined does not exist, but null does. Typeof (null) = object, but null is not an object. This is the
Just as we can write in this form:
CopyCode The Code is as follows: function Hello (){
Alert ("hello ");
}
Hello ();
VaR Hello = function (){
Alert ("hello ");
}
Hello ();
They are all the same.However, when we modify the functions, we will find a
The function of Eval is actually very simple. It is to pass a string to the JS interpreter, which is interpreted as JavaScript by the javascript interpreter.
Code And execute it.
The simplest example is as follows:
Copy code The Code is as follows:
Three main features of object-oriented language: inheritance, polymorphism, and encapsulation. Although JavaScript does not provide a natural syntax implementation, we can use prototype and other techniques to implement it, therefore, this statement
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