javascript指南_JavaScript指南

javascript指南

by Ashay Mandwarya ?️??

由Ashay Mandwarya提供吗?

JavaScript指南 (A guide to this in JavaScript)

The this keyword hands-down is one of the most widely used and yet misunderstood in JavaScript. I’ll try to change that today.

this关键字hand-down是JavaScript中使用最广泛但仍被误解的关键字之一。 我今天将尝试更改它。

Let’s go back to the good old school days, when we learned about pronouns.

让我们回到过去的美好时光,那时我们了解了代词。

Phelps is swimming fast because he wants to win the race.

菲尔普斯游刃有余,因为想赢得比赛。

Note the use of the pronoun “he”. We don’t directly address Phelps here but use the pronoun he to refer to Phelps. Similarly JavaScript uses the this keyword as a referent to refer to the object in context i.e the subject.

注意代词“ he”的使用。 我们在这里没有直接提及菲尔普斯,而是使用他代词来指代菲尔普斯 类似地,JavaScript使用this关键字作为引用来引用上下文中的对象, 即subject

Example:

例:

var car= {make: "Lamborghini",model: "Huracán",fullName: function () {console.log(this.make+" " +this.model);console.log(car.make+ " " +car.model);}}car.fullName();

In the above code, we have an object car which has the properties make, model and fullName. The value of fullName is a function which prints the full name of the car using 2 different syntaxes.

在上面的代码中,我们有一个对象car ,其属性为makemodelfullNamefullName的值是一个函数,它使用两种不同的语法来打印汽车的全名。

  • Using this => this.make+” “ +this.model the this refers to the object in context which is car so this.make is effectively car.make and so is this.model .

    使用this =&g t; this.make+” “ +this.mod t; this.make+” “ +this.mod EL the t他是指对象在上下文中,其is c AR so this.ma Ke是有效ly car.m AKE等is this.mo德尔。

  • Using dot notation, we can access the properties of objects, car.make & car.model .

    使用点符号,我们可以访问对象的属性car.makecar.model

this就是它! (this is it!)

Now that we have understood what is this and it’s most basic usage, let’s make some rules of thumb so we can always remember.

现在我们已经明白了什么是this ,它是最基本的用法,让我们的一些经验法则,以便我们能够永远记住。

JS this关键字引用了它所属的对象。 (The JS this keyword refers to the object it belongs to.)
var car={make:'....'func:()=>{console.log(this.make)}}

The this in the above snippet belongs to the object car.

以上代码段中的this属于对象车。

根据使用情况,取不同的值 (It takes different values depending upon the usage)
  1. Inside a method.

    里面有个方法。
  2. Inside a function.

    在函数内部。
  3. Alone.

    单独。
  4. In an event.

    在一个事件中。
  5. call(), and apply().

    call()apply().

Inside a method

方法内部

When this is used inside a method, it refers to the owner object.

在方法内部使用this方法时,它引用所有者对象。

Functions defined inside an object are called methods. Let’s take our car example again.

在对象内部定义的函数称为方法。 让我们再以汽车为例。

var car= {make: "Lamborghini",model: "Huracán",fullName: function () {console.log(this.make+" " +this.model);console.log(car.make+ " " +car.model);}}car.fullName();

fullName() here is a method. The this inside this method belongs to car.

fullName()这是一个方法。 在this里面这个方法属于car

Inside a function

函数内部

this inside a function is a bit complicated. First thing to understand is that, like all objects have properties, likewise functions have properties too. Whenever that function is executed, it gets the this property, which is a variable with the value of the object that invokes it.

this函数里面有一点复杂。 首先要了解的是,就像所有对象都具有属性一样,函数也同样具有属性。 每当执行该函数时,它都会获得this属性, this属性是一个变量,具有调用它的对象的值。

this is really just a shortcut reference for the “antecedent object” — the invoking object. — javascriptissexy.com

实际上只是“先行对象”(调用对象)的快捷方式引用。 — javascriptissexy.com

If the function is not invoked by an object then the this inside the function belongs to the global object, which is called window. In this case this will refer to the values defined in the global scope. Let’s see an example for better understanding:

如果该函数未由对象调用,则函数内部的this属于全局对象,称为窗口。 在这种情况下,这将引用在全局范围内定义的值。 让我们看一个更好理解的例子:

var make= "Mclaren";var model= "720s"function fullName(){ console.log(this.make+ " " + this.model);}
var car = {    make:"Lamborghini",    model:"Huracán",    fullName:function () {    console.log (this.make + " " + this.model);    }}    car.fullName(); // Lmborghini Huracán    window.fullName(); // Mclaren 720S    fullName(); // Mclaren 720S

Here make, model and fullName are defined globally, while car object has an implementation of fullName as well. When invoked by the car object this referred to the properties defined inside the object. On the other hand, the other two function callings are the same and return the globally defined properties.

这里, make, modelfullName是全局定义的,而car对象也具有fullName的实现。 当由car对象调用时,这是指对象内部定义的属性。 另一方面,其他两个函数调用相同,并且返回全局定义的属性。

Alone

单独

When used alone not inside any function or object, this refers to the global object.

当单独使用而不是在任何函数或对象内使用时, this指的是全局对象。

The this here refers to the global name property.

这里的this是指全局名称属性。

In an event

在事件中

Events can be of any type, but for the sake of simplicity and clarity, let’s take a click event.

事件可以是任何类型,但是为了简单明了,让我们点击事件。

Whenever a button is clicked and an event is raised, it can call another function to do a certain task based on the click. If this is used inside that function, it will refer to the element which raised the event. In the DOM, all the elements are stored as objects. That is why when an event is raised it refers to that element, because that webpage element is actually an object inside the DOM.

每当单击按钮并引发事件时,它都可以调用其他函数来基于单击来执行某些任务。 如果this是该函数内部使用,它将指的是引发事件的元素。 在DOM中,所有元素都存储为对象。 这就是为什么在引发事件时它引用该元素的原因,因为该网页元素实际上是DOM中的一个对象

Example:

例:

<button onclick="this.style.display='none'">  Remove Me!</button>

call(), apply() & bind()

call(),apply()和bind()

  • bind: allows us to set the this value on methods.

    bind:允许我们在方法上设置this值。

  • call & apply: allow us to borrow functions and set the this value on function invocation.

    致电并申请:允许我们借用功能并设置this 函数调用的值。

Call, Bind and Apply are in themselves a topic of another post. They are very important, and explaining them here is not possible as we should know all about this to know the usage of these functions.

呼叫,绑定和应用本身就是另一篇文章的主题。 它们非常重要,在这里无法对其进行解释,因为我们应该了解所有this知识,才能了解这些功能的用法。

最棘手的部分 (The trickiest part)

If understood well, this make our work easier in a way. But there are some cases where it is misunderstood.

如果了解得很好, this将使我们的工作更加轻松。 但是在某些情况下,它会被误解。

范例1。 (Example 1.)
var car = {make:"Lamborghini",model:"Huracán",name:null,fullName:function () {this.name=this.make + " " + this.model;console.log (this.name);}}
var anotherCar={make:"Ferrari",model:"Italia",name:null}
anotherCar.name= car.fullName();

We get an unexpected result here. We borrowed a method that uses this from another object, but the problem here is that the method is only assigned to anotherCar function but is actually invoked on car object. That’s why we get the result as Lamborghini and not Ferrari.

我们在这里得到了意外的结果。 我们从另一个对象借用了一个使用this方法的方法,但是这里的问题是该方法仅分配给anotherCar函数,但实际上是在car对象上调用的。 这就是为什么我们得到的结果是兰博基尼而不是法拉利。

To resolve this, we use the call() method.

为了解决这个问题,我们使用call()方法。

Here the call() method calls fullName() on anotherCar object which originally does not have the fullName() function.

在这里, call()方法对另一个最初不具有fullName()函数的anotherCar对象调用fullName()

We can also see that, when we log the car.name and anotherCar.name we get the result for the latter not on former, which means that the function was indeed invoked on anotherCar and not on car.

我们还可以看到,当我们登录car.nameanotherCar.name我们得到的结果不是在前者上,这意味着该函数确实是在anotherCar而不是car上调用的。

示例2 (Example 2.)
var cars=[{ make: "Mclaren", model: "720s"},{make: "Ferrari",model: "Italia"}]
var car = {cars:[{make:"Lamborghini", model:"Huracán"}],fullName:function () {console.log(this.cars[0].make + " " + this.cars[0].model);}}var vehicle=car.fullName;vehicle()

In the above snippet we have a global object called cars and we have the same name object inside the car object. The fullName() method is then assigned to the vehicle variable which is then called. The variable belongs to the global object so this calls the global cars object instead of the cars object because of the context.

在上面的代码片段中,我们有一个名为cars的全局对象,并且在car对象内有相同名称的对象。 然后将fullName()方法分配给随后被调用的车辆变量。 变量属于全局对象,因此this要求全球cars对象,而不是cars ,因为上下文对象。

To resolve that we use .bind() function to solve the issue.

为了解决这个问题,我们使用.bind()函数来解决此问题。

Binding helps us with specifically setting the this value and hence the vehicle variable explicitly points to the car object and not the global object, so this lies in the context of the car object.

绑定可帮助我们专门设置this值,因此,车辆变量显式指向汽车对象而不是全局对象,因此这位于car对象的上下文中。

范例3。 (Example 3.)
var car = {cars:[{make:"Lamborghini",model:"Huracán"},{ make: "Mclaren", model: "720s"},{make: "Ferrari",model: "Italia"}],fullName:function(){this.cars.forEach(()=>{console.log (this.make + " " + this.model);})}}car.fullName();

In the above snippet, the fullName() calls upon a function which iterated through the cars array using forEach. Inside the forEach there is an anonymous function where this loses context. A function inside a function in JavaScript is called a closure. Closures are very important and widely used in JavaScript.

在上面的代码段中, fullName()调用了一个函数,该函数使用forEach遍历cars数组。 在forEach内部有一个匿名函数,该函数会丢失上下文。 JavaScript中的函数内部的函数称为closureClosures非常重要,并且在JavaScript中广泛使用。

Another important concept playing a role here is scope. A variable inside a function cannot access variables and properties outside its scope. this inside the anon function cannot access this outside it. So this has nowhere to go but to point to global object. But there, no property is defined for this to access so undefined is printed.

在这里起作用的另一个重要概念是scope 。 函数内部的变量无法访问其scope之外的变量和属性。 this在不久的内部功能无法访问this外面。 因此,除了指向全局对象之外, this无处可走。 但是在那里,没有this访问定义任何属性,因此undefined被打印。

A workaround for the above is that we can assign a variable the value of this, outside the anonymous function and then use it inside it.

上面的解决方法是,我们可以在匿名函数外部为变量赋this的值,然后在其内部使用它。

Here, the self variable contains the value of this which is used with the inner function thus giving us the output.

在此,自变量包含此值, this值与内部函数一起使用,从而为我们提供输出。

范例4。 (Example 4.)
var car= {make: "Lamborghini",model: "Huracán",fullName: function (cars) {cars.forEach(function(vehicle){console.log(vehicle +" "+ this.model);})}}car.fullName(['lambo','ferrari','porsche']);

This is a revisited example, in which this wasn't accessible so we preserved it's value by using a variable called self. Let's use arrow function to solve the same:

这是一个重新例子,在this ,所以我们用所谓的自变量保留了它的价值是无法访问。 让我们使用箭头函数来解决相同的问题:

As you can see, using an arrow function in forEach() automatically solves the problem and we don’t have to do bind, or give the this value to some other variable. This is because arrow functions bind their context so this actually refers to the originating context, or the originating object.

如您所见,在forEach()使用箭头函数可以自动解决问题,我们不必绑定,也不必将this值赋予其他变量。 这是因为箭头功能结合它们的上下文,以便this实际上指的是始发上下文,或始发对象。

范例5。 (Example 5.)
var car= {make: "Lamborghini",model: "Huracán",fullName: function () {console.log(this.make +" "+ this.model);}}var truck= {make: "Tesla",model: "Truck",fullName: function (callback) {console.log(this.make +" "+ this.model);callback();}}truck.fullName(car.fullName);

The above code consists of two identical objects, with one containing a callback function. A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine.

上面的代码由两个相同的对象组成,其中一个包含一个回调函数。 回调函数是作为参数传递给另一个函数的函数,然后在外部函数内部调用该回调函数以完成某种例程。

Here, the truck object’s fullName method consists of a callback which is also invoked inside it. Our car object is as before. When we invoke the truck’s fullName method with the callback(argument) as the fullName method of the car object, we get output as Tesla Truck and undefined undefined.

在这里,卡车对象的fullName方法包含一个回调 ,该回调也在其内部被调用 我们的汽车对象和以前一样。 当我们调用卡车的fullName法回调(参数)的fullName汽车对象的方法,我们得到的输出Tesla Truckundefined undefined.

After reading about this some of you might have gotten a hunch that car.fullName would print the model and make of the truck object, but to your disappointment, this again played a trick on us. Here the car.fullName is passed as an argument and is not actually invoked by the truck object. The callback invokes the car object method, but note that the actual call site for the function is the callback which binds this to the global object. It's a bit confusing, so read it again!

在阅读了this内容后,您可能已经预感到car.fullName会打印出卡车对象的模型和制造商,但是令您失望的是, this再次对我们起到了欺骗作用。 这里car.fullName作为参数传递,而卡车对象实际上并未调用。 回调调用car对象方法,但请注意,该函数的实际调用站点是将其绑定到全局对象的回调。 这有点令人困惑,所以请再次阅读!

Here to get clarity, we print this itself. We can see that the this of callback is given a global scope. So to get a result we create global make and model properties.

为了清楚起见,我们this其本身打印出来。 我们可以看到回调的this被赋予了全局范围。 因此,为了获得结果,我们创建了全局makemodel属性。

Again, running the same code with global make and model properties we finally get the answer to the global this. This proves that this references the global object.

同样,使用全局makemodel属性运行相同的代码,我们终于得到了全局this的答案。 这证明this引用了全局对象。

To get the results which we desire, the car.fullName result we will again use bind() to hard-bind the car object to the callback, which will make everything right again.

为了得到我们想要的结果car.fullName结果,我们将再次使用bind()硬绑定车对象的回调,这将便又让一切。

解决了! (Solved!)

No doubt that this is very useful, but has it's own pitfalls too. Hope I made it quite easy for you to understand. If you want more content simplified like this, follow me on Medium. Please leave your responses and share this if you liked it.

毫无疑问, this非常有用,但也有其自身的陷阱。 希望我使您很容易理解。 如果您想像这样简化更多内容,请在Medium上关注我。 如果您喜欢,请留下您的答复并分享。

翻译自: https://www.freecodecamp.org/news/a-guide-to-this-in-javascript-e3b9daef4df1/

javascript指南

JavaScript权威指南 犀牛书 Chapter 1. Introduction to JavaScript Section 1.1. JavaScript Myths Section 1.2. Versions of JavaScript Section 1.3. Client-Side JavaScript Section 1.4. JavaScript in Other Contexts Section 1.5. Client-Side JavaScript: Executable Content in Web Pages Section 1.6. Client-Side JavaScript Features Section 1.7. JavaScript Security Section 1.8. Example: Computing Loan Payments with JavaScript Section 1.9. Using the Rest of This Book Section 1.10. Exploring JavaScript Part I: Core JavaScript Chapter 2. Lexical Structure Section 2.1. Character Set Section 2.2. Case Sensitivity Section 2.3. Whitespace and Line Breaks Section 2.4. Optional Semicolons Section 2.5. Comments Section 2.6. Literals Section 2.7. Identifiers Section 2.8. Reserved Words Chapter 3. Data Types and Values Section 3.1. Numbers Section 3.2. Strings Section 3.3. Boolean Values Section 3.4. Functions Section 3.5. Objects Section 3.6. Arrays Section 3.7. null Section 3.8. undefined Section 3.9. The Date Object Section 3.10. Regular Expressions Section 3.11. Error Objects Section 3.12. Primitive Data Type Wrapper Objects Chapter 4. Variables Section 4.1. Variable Typing Section 4.2. Variable Declaration Section 4.3. Variable Scope Section 4.4. Primitive Types and Reference Types Section 4.5. Garbage Collection Section 4.6. Variables as Properties Section 4.7. Variable Scope Revisited Chapter 5. Expressions and Operators Section 5.1. Expressions Section 5.2. Operator Overview Section 5.3. Arithmetic Operators Section 5.4. Equality Operators Section 5.5. Relational Operators Section 5.6. String Operators Section 5.7. Logical Operators Section 5.8. Bitwise Operators Section 5.9. Assignment Operators Section 5.10. Miscellaneous Operators Chapter 6. Statements Section 6.1. Expression Statements Section 6.2. Compound Statements Section 6.3. if Section 6.4. else if Section 6.5. switch Section 6.6. while Section 6.7. do/while Section 6.8. for Section 6.9. for/in Section 6.10. Labels Section 6.11. break Section 6.12. continue Section 6.13. var Section 6.14. function Section 6.15. return Section 6.16. throw Section 6.17. try/catch/finally Section 6.18. with Section 6.19. The Empty Statement Section 6.20. Summary of JavaScript Statements Chapter 7. Functions Section 7.1. Defining and Invoking Functions Section 7.2. Functions as Data Section 7.3. Function Scope: The Call Object Section 7.4. Function Arguments: The Arguments Object Section 7.5. Function Properties and Methods Chapter 8. Objects Section 8.1. Objects and Properties Section 8.2. Constructors Section 8.3. Methods Section 8.4. Prototypes and Inheritance Section 8.5. Object-Oriented JavaScript Section 8.6. Objects as Associative Arrays Section 8.7. Object Properties and Methods Chapter 9. Arrays Section 9.1. Arrays and Array Elements Section 9.2. Array Methods Chapter 10. Pattern Matching with Regular Expressions Section 10.1. Defining Regular Expressions Section 10.2. String Methods for Pattern Matching Section 10.3. The RegExp Object Chapter 11. Further Topics in JavaScript Section 11.1. Data Type Conversion Section 11.2. By Value Versus by Reference Section 11.3. Garbage Collection Section 11.4. Lexical Scoping and Nested Functions Section 11.5. The Function( ) Constructor and Function Literals Section 11.6. Netscape's JavaScript 1.2 Incompatibilities Part II: Client-Side JavaScript Chapter 12. JavaScript in Web Browsers Section 12.1. The Web Browser Environment Section 12.2. Embedding JavaScript in HTML Section 12.3. Execution of JavaScript Programs Chapter 13. Windows and Frames Section 13.1. Window Overview Section 13.2. Simple Dialog Boxes Section 13.3. The Status Line Section 13.4. Timeouts and Intervals Section 13.5. Error Handling Section 13.6. The Navigator Object Section 13.7. The Screen Object Section 13.8. Window Control Methods Section 13.9. The Location Object Section 13.10. The History Object Section 13.11. Multiple Windows and Frames Chapter 14. The Document Object Section 14.1. Document Overview Section 14.2. Dynamically Generated Documents Section 14.3. Document Color Properties Section 14.4. Document Information Properties Section 14.5. Forms Section 14.6. Images Section 14.7. Links Section 14.8. Anchors Section 14.9. Applets Section 14.10. Embedded Data Chapter 15. Forms and Form Elements Section 15.1. The Form Object Section 15.2. Defining Form Elements Section 15.3. Scripting Form Elements Section 15.4. Form Verification Example Chapter 16. Scripting Cookies Section 16.1. An Overview of Cookies Section 16.2. Storing Cookies Section 16.3. Reading Cookies Section 16.4. Cookie Example Chapter 17. The Document Object Model Section 17.1. An Overview of the DOM Section 17.2. Using the Core DOM API Section 17.3. DOM Compatibility with Internet Explorer 4 Section 17.4. DOM Compatibility with Netscape 4 Section 17.5. Convenience Methods: The Traversal and Range APIs Chapter 18. Cascading Style Sheets and Dynamic HTML Section 18.1. Styles and Style Sheets with CSS Section 18.2. Element Positioning with CSS Section 18.3. Scripting Styles Section 18.4. DHTML in Fourth-Generation Browsers Section 18.5. Other DOM APIs for Styles and Style Sheets Chapter 19. Events and Event Handling Section 19.1. Basic Event Handling Section 19.2. Advanced Event Handling with DOM Level 2 Section 19.3. The Internet Explorer Event Model Section 19.4. The Netscape 4 Event Model Chapter 20. Compatibility Techniques Section 20.1. Platform and Browser Compatibility Section 20.2. Language Version Compatibility Section 20.3. Compatibility with Non-JavaScript Browsers Chapter 21. JavaScript Security Section 21.1. JavaScript and Security Section 21.2. Restricted Features Section 21.3. The Same-Origin Policy Section 21.4. Security Zones and Signed Scripts Chapter 22. Using Java with JavaScript Section 22.1. Scripting Java Applets Section 22.2. Using JavaScript from Java Section 22.3. Using Java Classes Directly Section 22.4. LiveConnect Data Types Section 22.5. LiveConnect Data Conversion Section 22.6. JavaScript Conversion of JavaObjects Section 22.7. Java-to-JavaScript Data Conversion Part III: Core JavaScript Reference Chapter 23. Core JavaScript Reference Sample Entry arguments[ ] Arguments Arguments.callee Arguments.length Array Array.concat( ) Array.join( ) Array.length Array.pop( ) Array.push( ) Array.reverse( ) Array.shift( ) Array.slice( ) Array.sort( ) Array.splice( ) Array.toLocaleString( ) Array.toString( ) Array.unshift( ) Boolean Boolean.toString( ) Boolean.valueOf( ) Date Date.getDate( ) Date.getDay( ) Date.getFullYear( ) Date.getHours( ) Date.getMilliseconds( ) Date.getMinutes( ) Date.getMonth( ) Date.getSeconds( ) Date.getTime( ) Date.getTimezoneOffset( ) Date.getUTCDate( ) Date.getUTCDay( ) Date.getUTCFullYear( ) Date.getUTCHours( ) Date.getUTCMilliseconds( ) Date.getUTCMinutes( ) Date.getUTCMonth( ) Date.getUTCSeconds( ) Date.getYear( ) Date.parse( ) Date.setDate( ) Date.setFullYear( ) Date.setHours( ) Date.setMilliseconds( ) Date.setMinutes( ) Date.setMonth( ) Date.setSeconds( ) Date.setTime( ) Date.setUTCDate( ) Date.setUTCFullYear( ) Date.setUTCHours( ) Date.setUTCMilliseconds( ) Date.setUTCMinutes( ) Date.setUTCMonth( ) Date.setUTCSeconds( ) Date.setYear( ) Date.toDateString( ) Date.toGMTString( ) Date.toLocaleDateString( ) Date.toLocaleString( ) Date.toLocaleTimeString( ) Date.toString( ) Date.toTimeString( ) Date.toUTCString( ) Date.UTC( ) Date.valueOf( ) decodeURI( ) decodeURIComponent( ) encodeURI( ) encodeURIComponent( ) Error Error.message Error.name Error.toString( ) escape( ) eval( ) EvalError Function Function.apply( ) Function.arguments[] Function.call( ) Function.caller Function.length Function.prototype Function.toString( ) Global Infinity isFinite( ) isNaN( ) Math Math.abs( ) Math.acos( ) Math.asin( ) Math.atan( ) Math.atan2( ) Math.ceil( ) Math.cos( ) Math.E Math.exp( ) Math.floor( ) Math.LN10 Math.LN2 Math.log( ) Math.LOG10E Math.LOG2E Math.max( ) Math.min( ) Math.PI Math.pow( ) Math.random( ) Math.round( ) Math.sin( ) Math.sqrt( ) Math.SQRT1_2 Math.SQRT2 Math.tan( ) NaN Number Number.MAX_VALUE Number.MIN_VALUE Number.NaN Number.NEGATIVE_INFINITY Number.POSITIVE_INFINITY Number.toExponential( ) Number.toFixed( ) Number.toLocaleString( ) Number.toPrecision( ) Number.toString( ) Number.valueOf( ) Object Object.constructor Object.hasOwnProperty( ) Object.isPrototypeOf( ) Object.propertyIsEnumerable( ) Object.toLocaleString( ) Object.toString( ) Object.valueOf( ) parseFloat( ) parseInt( ) RangeError ReferenceError RegExp RegExp.exec( ) RegExp.global RegExp.ignoreCase RegExp.lastIndex RegExp.source RegExp.test( ) RegExp.toString( ) String String.charAt( ) String.charCodeAt( ) String.concat( ) String.fromCharCode( ) String.indexOf( ) String.lastIndexOf( ) String.length String.localeCompare( ) String.match( ) String.replace( ) String.search( ) String.slice( ) String.split( ) String.substr( ) String.substring( ) String.toLocaleLowerCase( ) String.toLocaleUpperCase( ) String.toLowerCase( ) String.toString( ) String.toUpperCase( ) String.valueOf( ) SyntaxError TypeError undefined unescape( ) URIError Part IV: Client-Side JavaScript Reference Chapter 24. Client-Side JavaScript Reference Sample Entry Anchor Applet Area Button Button.onclick Checkbox Checkbox.onclick Document Document.all[] Document.captureEvents( ) Document.clear( ) Document.close( ) Document.cookie Document.domain Document.elementFromPoint( ) Document.getSelection( ) Document.handleEvent( ) Document.lastModified Document.links[] Document.open( ) Document.releaseEvents( ) Document.routeEvent( ) Document.URL Document.write( ) Document.writeln( ) Element Event FileUpload FileUpload.onchange Form Form.elements[] Form.onreset Form.onsubmit Form.reset( ) Form.submit( ) Form.target Frame getClass( ) Hidden History History.back( ) History.forward( ) History.go( ) HTMLElement HTMLElement.contains( ) HTMLElement.getAttribute( ) HTMLElement.handleEvent( ) HTMLElement.insertAdjacentHTML( ) HTMLElement.insertAdjacentText( ) HTMLElement.onclick HTMLElement.ondblclick HTMLElement.onhelp HTMLElement.onkeydown HTMLElement.onkeypress HTMLElement.onkeyup HTMLElement.onmousedown HTMLElement.onmousemove HTMLElement.onmouseout HTMLElement.onmouseover HTMLElement.onmouseup HTMLElement.removeAttribute( ) HTMLElement.scrollIntoView( ) HTMLElement.setAttribute( ) Image Image.onabort Image.onerror Image.onload Input Input.blur( ) Input.click( ) Input.focus( ) Input.name Input.onblur Input.onchange Input.onclick Input.onfocus Input.select( ) Input.type Input.value JavaArray JavaClass JavaObject JavaPackage JSObject JSObject.call( ) JSObject.eval( ) JSObject.getMember( ) JSObject.getSlot( ) JSObject.getWindow( ) JSObject.removeMember( ) JSObject.setMember( ) JSObject.setSlot( ) JSObject.toString( ) Layer Layer.captureEvents( ) Layer.handleEvent( ) Layer.load( ) Layer.moveAbove( ) Layer.moveBelow( ) Layer.moveBy( ) Layer.moveTo( ) Layer.moveToAbsolute( ) Layer.offset( ) Layer.releaseEvents( ) Layer.resizeBy( ) Layer.resizeTo( ) Layer.routeEvent( ) Link Link.onclick Link.onmouseout Link.onmouseover Link.target Location Location.reload( ) Location.replace( ) MimeType Navigator Navigator.javaEnabled( ) Navigator.plugins.refresh( ) Option Password Plugin Radio Radio.onclick Reset Reset.onclick Screen Select Select.onchange Select.options[] Style Submit Submit.onclick Text Text.onchange Textarea Textarea.onchange URL Window Window.alert( ) Window.back( ) Window.blur( ) Window.captureEvents( ) Window.clearInterval( ) Window.clearTimeout( ) Window.close( ) Window.confirm( ) Window.defaultStatus Window.focus( ) Window.forward( ) Window.handleEvent( ) Window.home( ) Window.moveBy( ) Window.moveTo( ) Window.name Window.navigate( ) Window.onblur Window.onerror Window.onfocus Window.onload Window.onmove Window.onresize Window.onunload Window.open( ) Window.print( ) Window.prompt( ) Window.releaseEvents( ) Window.resizeBy( ) Window.resizeTo( ) Window.routeEvent( ) Window.scroll( ) Window.scrollBy( ) Window.scrollTo( ) Window.setInterval( ) Window.setTimeout( ) Window.status Window.stop( ) Part V: W3C DOM Reference Chapter 25. W3C DOM Reference Sample Entry AbstractView AbstractView.getComputedStyle( ) Attr CDATASection CharacterData CharacterData.appendData( ) CharacterData.deleteData( ) CharacterData.insertData( ) CharacterData.replaceData( ) CharacterData.substringData( ) Comment Counter CSS2Properties CSSCharsetRule CSSFontFaceRule CSSImportRule CSSMediaRule CSSMediaRule.deleteRule( ) CSSMediaRule.insertRule( ) CSSPageRule CSSPrimitiveValue CSSPrimitiveValue.getCounterValue( ) CSSPrimitiveValue.getFloatValue( ) CSSPrimitiveValue.getRectValue( ) CSSPrimitiveValue.getRGBColorValue( ) CSSPrimitiveValue.getStringValue( ) CSSPrimitiveValue.setFloatValue( ) CSSPrimitiveValue.setStringValue( ) CSSRule CSSRuleList CSSRuleList.item( ) CSSStyleDeclaration CSSStyleDeclaration.getPropertyCSSValue( ) CSSStyleDeclaration.getPropertyPriority( ) CSSStyleDeclaration.getPropertyValue( ) CSSStyleDeclaration.item( ) CSSStyleDeclaration.removeProperty( ) CSSStyleDeclaration.setProperty( ) CSSStyleRule CSSStyleSheet CSSStyleSheet.deleteRule( ) CSSStyleSheet.insertRule( ) CSSUnknownRule CSSValue CSSValueList CSSValueList.item( ) Document Document.createAttribute( ) Document.createAttributeNS( ) Document.createCDATASection( ) Document.createComment( ) Document.createDocumentFragment( ) Document.createElement( ) Document.createElementNS( ) Document.createEntityReference( ) Document.createEvent( ) Document.createNodeIterator( ) Document.createProcessingInstruction( ) Document.createRange( ) Document.createTextNode( ) Document.createTreeWalker( ) Document.getElementById( ) Document.getElementsByTagName( ) Document.getElementsByTagNameNS( ) Document.getOverrideStyle( ) Document.importNode( ) DocumentCSS DocumentEvent DocumentFragment DocumentRange DocumentStyle DocumentTraversal DocumentType DocumentView DOMException DOMImplementation DOMImplementation.createCSSStyleSheet( ) DOMImplementation.createDocument( ) DOMImplementation.createDocumentType( ) DOMImplementation.createHTMLDocument( ) DOMImplementation.hasFeature( ) DOMImplementationCSS Element Element.getAttribute( ) Element.getAttributeNode( ) Element.getAttributeNodeNS( ) Element.getAttributeNS( ) Element.getElementsByTagName( ) Element.getElementsByTagNameNS( ) Element.hasAttribute( ) Element.hasAttributeNS( ) Element.removeAttribute( ) Element.removeAttributeNode( ) Element.removeAttributeNS( ) Element.setAttribute( ) Element.setAttributeNode( ) Element.setAttributeNodeNS( ) Element.setAttributeNS( ) ElementCSSInlineStyle Entity EntityReference Event Event.initEvent( ) Event.preventDefault( ) Event.stopPropagation( ) EventException EventListener EventTarget EventTarget.addEventListener( ) EventTarget.dispatchEvent( ) EventTarget.removeEventListener( ) HTMLAnchorElement HTMLAnchorElement.blur( ) HTMLAnchorElement.focus( ) HTMLBodyElement HTMLCollection HTMLCollection.item( ) HTMLCollection.namedItem( ) HTMLDocument HTMLDocument.close( ) HTMLDocument.getElementById( ) HTMLDocument.getElementsByName( ) HTMLDocument.open( ) HTMLDocument.write( ) HTMLDocument.writeln( ) HTMLDOMImplementation HTMLElement HTMLFormElement HTMLFormElement.reset( ) HTMLFormElement.submit( ) HTMLInputElement HTMLInputElement.blur( ) HTMLInputElement.click( ) HTMLInputElement.focus( ) HTMLInputElement.select( ) HTMLOptionElement HTMLSelectElement HTMLSelectElement.add( ) HTMLSelectElement.blur( ) HTMLSelectElement.focus( ) HTMLSelectElement.remove( ) HTMLTableCaptionElement HTMLTableCellElement HTMLTableColElement HTMLTableElement HTMLTableElement.createCaption( ) HTMLTableElement.createTFoot( ) HTMLTableElement.createTHead( ) HTMLTableElement.deleteCaption( ) HTMLTableElement.deleteRow( ) HTMLTableElement.deleteTFoot( ) HTMLTableElement.deleteTHead( ) HTMLTableElement.insertRow( ) HTMLTableRowElement HTMLTableRowElement.deleteCell( ) HTMLTableRowElement.insertCell( ) HTMLTableSectionElement HTMLTableSectionElement.deleteRow( ) HTMLTableSectionElement.insertRow( ) HTMLTextAreaElement HTMLTextAreaElement.blur( ) HTMLTextAreaElement.focus( ) HTMLTextAreaElement.select( ) LinkStyle MediaList MediaList.appendMedium( ) MediaList.deleteMedium( ) MediaList.item( ) MouseEvent MouseEvent.initMouseEvent( ) MutationEvent MutationEvent.initMutationEvent( ) NamedNodeMap NamedNodeMap.getNamedItem( ) NamedNodeMap.getNamedItemNS( ) NamedNodeMap.item( ) NamedNodeMap.removeNamedItem( ) NamedNodeMap.removeNamedItemNS( ) NamedNodeMap.setNamedItem( ) NamedNodeMap.setNamedItemNS( ) Node Node.appendChild( ) Node.cloneNode( ) Node.hasAttributes( ) Node.hasChildNodes( ) Node.insertBefore( ) Node.isSupported( ) Node.normalize( ) Node.removeChild( ) Node.replaceChild( ) NodeFilter NodeIterator NodeIterator.detach( ) NodeIterator.nextNode( ) NodeIterator.previousNode( ) NodeList NodeList.item( ) Notation ProcessingInstruction Range Range.cloneContents( ) Range.cloneRange( ) Range.collapse( ) Range.compareBoundaryPoints( ) Range.deleteContents( ) Range.detach( ) Range.extractContents( ) Range.insertNode( ) Range.selectNode( ) Range.selectNodeContents( ) Range.setEnd( ) Range.setEndAfter( ) Range.setEndBefore( ) Range.setStart( ) Range.setStartAfter( ) Range.setStartBefore( ) Range.surroundContents( ) Range.toString( ) RangeException Rect RGBColor StyleSheet StyleSheetList StyleSheetList.item( ) Text Text.splitText( ) TreeWalker TreeWalker.firstChild( ) TreeWalker.lastChild( ) TreeWalker.nextNode( ) TreeWalker.nextSibling( ) TreeWalker.parentNode( ) TreeWalker.previousNode( ) TreeWalker.previousSibling( ) UIEvent UIEvent.initUIEvent( ) ViewCSS Part VI: Class, Property, Method, and Event Handler Index Chapter 26. Class, Property, Method, and Event Handler Index Section 26.1. A Section 26.2. B Section 26.3. C Section 26.4. D Section 26.5. E Section 26.6. F Section 26.7. G Section 26.8. H Section 26.9. I Section 26.10. J Section 26.11. K Section 26.12. L Section 26.13. M Section 26.14. N Section 26.15. O Section 26.16. P Section 26.17. Q Section 26.18. R Section 26.19. S Section 26.20. T Section 26.21. U Section 26.22. V Section 26.23. W Section 26.24. X Section 26.25. Y Section 26.26. Z
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值