1. Trang chủ
  2. » Công Nghệ Thông Tin

Javascript tutorials

37 126 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Events in JavaScript
Trường học University of Example
Chuyên ngành Computer Science
Thể loại Tutorial
Năm xuất bản 2023
Thành phố Sample City
Định dạng
Số trang 37
Dung lượng 514,5 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Bubbles: Yes Cancelable: No Event object: - Occurs when the selection, the checked state or the contents of an element have changed.. Bubbles: Yes Cancelable: Yes Event object: MouseEven

Trang 2

objects If you need the event objects in a hierarchical form, see the page for the Event interface Bubbles Cancelable Event object

Name that can be used for

the addEventListener , remove

EventListener and event

initialization ( initEvent , )

methods.

Name that can be used for event attributes (HTML), shorthand form (e.g obj.onclick) and for the attachEvent , detachEvent and fir eEvent methods.

Description

Occurs when the user aborts the loading of an img or input:image element.

Bubbles: YesCancelable: No Event object: UIEvent

Occurs when an element becomes active.

Bubbles: Yes Cancelable: No Event object: UIEvent

Occurs when the browser has built the contents of the current document for printing or for the print preview.

Bubbles: No Cancelable: No Event object: Event

Occurs before an element becomes active.

Bubbles: Yes Cancelable: Partially Event object: UIEvent

beforecut onbeforecut Occurs before the selection is cut from the document and provides a

possibility to enable the Cut menu item.

Bubbles: Yes Cancelable: Yes

Trang 3

Occurs on the active element before it loses the active state.

Bubbles: Yes Cancelable: Yes Event object: UIEvent

Occurs before an input:file , input:password , input:text or textarea element or

an element in an editable region becomes a UI-activated.

Bubbles: Yes Cancelable: Yes Event object: -

beforeunload onbeforeunload

Occurs before the browser unloads the document and provides a possibility

to display a confirmation dialog, where the user can confirm whether he wants to stay or leave the current page.

Bubbles: No Cancelable: Yes Event object:

Trang 4

Bubbles: Yes Cancelable: Yes Event object: -

Occurs when an element loses focus.

Bubbles: No Cancelable: No Event object:

Occurs on a data source object when the data in it has changed.

Bubbles: Yes Cancelable: No Event object: -

Occurs when the selection, the checked state or the contents of an element have changed In some cases, it only occurs when the element loses the focus.

Bubbles: No Cancelable: No Event object: Event

-Occurs when the state of a checkbox has changed.

Bubbles: No Cancelable: No Event object: Event

Occurs when the user clicks on an element.

Bubbles: Yes Cancelable: Yes Event object: MouseEvent

- oncontrolselect Occurs before a control is selected in an editable region.

Bubbles: Yes Cancelable: Yes

Trang 5

Event object:

Occurs before the selection is copied to the clipboard.

Bubbles: Yes Cancelable: Yes Event object:

Occurs on a data source object when all its data becomes available.

Bubbles: Yes Cancelable: No Event object: -

Occurs when the user double clicks on an element.

Bubbles: Yes Cancelable: Yes Event object: MouseEvent

Occurs on the active element when it loses the active state.

Bubbles: Yes Cancelable: No Event object: UIEvent

Trang 6

DOMActivate

-Occurs when an element becomes active.

Bubbles: Yes Cancelable: Yes Event object: UIEvent

-Fires when a script changes the value of a TextNode

Bubbles: Yes Cancelable: No Event object: MutationEvent

-Occurs before an element receives focus.

Bubbles: Yes Cancelable: No Event object: UIEvent

-Occurs before an element loses the focus.

Bubbles: Yes Cancelable: No Event object: UIEvent

-Occurs when the mouse wheel rolls.

Bubbles: No Cancelable: No Event object:

-Occurs on a node when it is added to an element.

Bubbles: Yes Cancelable: No Event object: MutationEvent

DOMNodeInsertedIntoDocu

-Occurs on a node when it is inserted into the document.

Bubbles: No Cancelable: No Event object: MutationEvent

DOMNodeRemoved - Occurs on a node when it is removed from its parent.

Bubbles: Yes Cancelable: No

Trang 7

Event object: MutationEvent

DOMNodeRemovedFromDo

-Occurs on a node when it is removed from the document.

Bubbles: No Cancelable: No Event object: MutationEvent

Occurs periodically on the source element during the drag operation.

Bubbles: Yes Cancelable: Yes Event object:

-Occurs on a possible target element when the dragged data is dropped on it.

Bubbles: Yes Cancelable: Yes Event object: MouseEvent

Trang 8

-Occurs on the source element when the user starts the drag operation.

Bubbles: Yes Cancelable: Yes Event object:

MouseEvent

3.5

DragEvent

3.5

dragleave ondragleave Occurs on an element when the user moves the mouse pointer out of it

during a drag operation.

Bubbles: Yes Cancelable: Yes Event object:

DragEvent

9 3.5

Trang 9

Occurs on the source element when the user starts the drag operation.

Bubbles: Yes Cancelable: Yes Event object:

DragEvent

9 3.5

MouseEvent

Occurs on a possible target element when the dragged data is dropped on it.

Bubbles: Yes Cancelable: Yes Event object:

DragEvent

9 3.5

MouseEvent

Fires when an error occurs while loading an external file.

Bubbles: No Cancelable: Yes Event object: Event

error (window) onerror (window)

Fires when a script error occurs.

Bubbles: No Cancelable: Yes Event object: -

- onerrorupdate Occurs on a databound object when it cannot update the data in the data

source object.

Trang 10

Bubbles: Yes Cancelable: No Event object: -

Occurs after a filter has changed or finished a transition.

Bubbles: No Cancelable: No Event object: -

Occurs when a marquee element has finished the scrolling animation.

Bubbles: No Cancelable: Yes Event object: Event

Occurs when an element receives focus.

Bubbles: No Cancelable: No Event object:

FocusEvent

9

Event

Occurs before an element receives focus.

Bubbles: Yes Cancelable: No Event object: FocusEvent

Occurs after an element loses focus.

Bubbles: Yes Cancelable: No Event object: FocusEvent

Occurs after the user has pressed the F1 key.

Bubbles: Yes Cancelable: Yes Event object: Event

Occurs when the text content of an element is changed through the user interface.

Bubbles: No Cancelable: No Event object: Event

keydown onkeydown Occurs on an element that has the focus when a key is pressed down and

Trang 11

occurs periodically until the key is released.

Bubbles: Yes Cancelable: Yes Event object: KeyboardEvent

Occurs on an element that has the focus when the user releases a key.

Bubbles: Yes Cancelable: No Event object: KeyboardEvent

Occurs when an object has been loaded.

Bubbles: No Cancelable: No Event object: Event

Occurs when the object loses the mouse capture.

Bubbles: No Cancelable: No Event object: -

Occurs when the user presses a mouse button over an element.

Bubbles: Yes Cancelable: Yes Event object: MouseEvent

Occurs when the user moves the mouse pointer into the area of an element.

Bubbles: No Cancelable: No Event object: MouseEvent

Occurs when the user moves the mouse pointer out of the element.

Bubbles: No Cancelable: No Event object: MouseEvent

Occurs when the user moves the mouse over the element.

Bubbles: Yes Cancelable: No Event object: MouseEvent

mouseout onmouseout Occurs when the user moves the mouse pointer out of the element.

Trang 12

Bubbles: Yes Cancelable: No Event object: MouseEvent

Occurs when the user moves the mouse pointer into the element.

Bubbles: Yes Cancelable: Yes Event object: MouseEvent

Occurs when the user releases a mouse button over an element.

Bubbles: Yes Cancelable: Yes Event object: MouseEvent

Occurs when the mouse wheel rolls.

Bubbles: Yes Cancelable: Yes Event object:

MouseWheelEvent

9

MouseEvent WheelEvent

Occurs when the position of an element's top-left corner is changed.

Bubbles: Yes Cancelable: No Event object: -

online ononline Occurs when the browser starts to work online.

Trang 13

Bubbles: No Cancelable: No Event object: Event

-Occurs when the contents or the size of an element is changed and it causes

a scrollbar to appear.

Bubbles: No Cancelable: No Event object: UIEvent

-Occurs when the contents or the size of an element is changed and it causes

a scrollbar to appear or disappear.

Bubbles: No Cancelable: No Event object: OverflowEvent

Occurs before the contents of the clipboard are pasted into the document.

Bubbles: Yes Cancelable: Yes Event object:

-Occurs when the state of a radio button has changed.

Bubbles: No Cancelable: No Event object: Event

readystatechange onreadystatechange

Occurs when the load state of the data that belongs to an element or a HTML document changes.

Bubbles: No Cancelable: No Event object: Event

readystatechange

(XMLDocument)

onreadystatechange (XMLDocument)

Occurs when the load state of the XMLDocument object changes.

Bubbles: No Cancelable: No Event object: -

readystatechange

(XMLHttpRequest)

onreadystatechange (XMLHttpRequest)

Occurs when the state of the request changes.

Bubbles: No Cancelable: No Event object: Event

Trang 14

reset onreset

Occurs on a form before it is reset.

Bubbles: No Cancelable: Yes Event object: Event

Occurs when the size of an object has changed.

Bubbles: No Cancelable: No Event object:

UIEvent

9

Event

Occurs when the user stops resizing an element in an editable region.

Bubbles: Yes Cancelable: No Event object: -

Occurs when the user starts to resize an element in an editable region.

Bubbles: Yes Cancelable: Yes Event object: -

Occurs on a data source object when the current row in it has changed.

Bubbles: Yes Cancelable: No Event object: -

Occurs on a data source object before the current row in it changes.

Bubbles: No Cancelable: Yes Event object: -

Occurs on a data source object before rows are deleted.

Bubbles: Yes Cancelable: No Event object: -

Occurs on a data source object when rows have been inserted.

Bubbles: Yes Cancelable: No Event object: -

scroll onscroll Occurs when the contents of an element have been scrolled.

Bubbles: No Cancelable: No Event object:

Trang 15

Occurs after some text has been selected in an element.

Bubbles: No Cancelable: Yes Event object:

Occurs at the start of a selection process.

Bubbles: Yes Cancelable: Yes Event object: Event

Occurs when a marquee element begins the scrolling animation and when a new loop starts.

Bubbles: No Cancelable: No Event object: Event

Occurs when the user aborts the loading of the document.

Bubbles: No Cancelable: No Event object: Event

Trang 16

Bubbles: Yes Cancelable: Yes Event object: TextEvent

-Occurs when the contents or the size of an element is changed and it causes

a scrollbar to disappear.

Bubbles: No Cancelable: No Event object: UIEvent

Occurs before the browser unloads the document.

Bubbles: No Cancelable: No Event object: Event

billingMethod = new Array(5);

coffees = [“French Roast”, “Columbian”, “Kona”] ;

emp[0] = “Casey Jones”;

emp[1] = “Phil Lesh”;

emp[2] = “August West”;

myArray = new Array (“Hello”, myVar, 3.14159)

concat Nối hai mảng và trả về một mảng mới

join Kết hợp tất cả các phần tử của một mảng thành một

Trang 17

pop Gỡ bỏ phần tử cuối cùng của một mảng và trả về phần tử

đó

push Bổ sung một hoặc nhiều phần tử vào cuối một mảng và

trả về độ dài mới của mảng

splice Chia nhỏ mảng ra, hàm này nhận vào 2 đối số, đối số thứ

nhất là vị trí của phần tử bắt đâu, đối số thứ hai là vị trí kết thúc

Ví dụ : mang.splice(1,2);

reverse Hoán vị các phần tử của một mảng: Phần tử mảng đầu

tiên trở thành phần tử cuối cùng và ngược lại

To create an array, either use the object constructor or the literal declaration, by assigning the variable a list of values after the declaration.

// A simple array with constructor.

var myArray1 = new Array( "hello", "world" );

// Literal declaration, the preferred way.

Trang 18

If the values are unknown, it is also possible to declare an empty array, and add elements either through functions or through accessing by index:

// Creating empty arrays and adding values

console.log( myArray ); // [ "hello", "world", undefined, "!" ];

If the size of the array is unknown, push() is far more safe You can both access and assign values to array items with the index.

// Accessing array items by index

var myArray = [ "hello", "world", "!" ];

Trang 19

console.log( myArray.length ); // 3

You will need the length property for looping through an array:

// For loops and arrays - a classic

var myArray = [ "hello", "world", "!" ];

for ( var i = 0 ; i < myArray.length; i = i + 1 ) {

console.log( myArray[ i ] );

}

Except when using for / in loops:

// For loops and arrays - alternate method

var myArray = [ "hello", "world", "!" ];

for ( var i in myArray ) {

// Joining elements

var myArray = [ "hello", "world", "!" ];

// The default separator is a comma.

console.log( myArray.join() ); // "hello,world,!"

Trang 20

// including an empty one.

console.log( myArray.join( "" ) ); // "helloworld!"

.pop()

.pop() removes the last element of an array It is the opposite method of push() :

// Pushing and popping

var myArray = [ "world" , "hello" ];

myArray.reverse(); // [ "hello", "world" ]

Trang 21

myArray.splice( index, length, values, );

Index – The starting index.

Length – The number of elements to remove.

Values – The values to be inserted at the index position.

Trang 22

The function takes up to three arguments:

Element – The element itself.

Index – The index of this element in the array.

Array – The array itself.

All of these are optional, but you will need at least the Element parameter in most cases.

// Native forEach()

function printElement( elem ) {

console.log( elem );

}

function printElementAndIndex( elem, index ) {

console.log( "Index " + index + ": " + elem );

}

function negateElement( elem, index, array ) {

array[ index ] = -elem;

Trang 23

parseInt("chuỗi"): biến chuỗi thành số nguyên

parseFloat("chuỗi"): biến chuỗi thành số thực

Number(<đối tượng>): chuyển đổi một "đối tượng" sang dạng số Nếu thất bại trả về NaN (not a number)

isNaN(<giá trị>): kiểm tra giá trị Nếu không phải số trả về true, ngược lại nếu là số trả về false

isFinite(number) : Hàm isFinite định giá trị một đối số để xác định xem nó

có phải là một số hữu hạn hay không.Nếu đối số là NaN, dương vô cùng hoặc âm vô cùng, phương thức này trả về false, ngoài ra nó trả về true

eval("chuỗi"): biến chuỗi thành biểu thức tính toán được, hoặc biến chuỗi thành lệnh thi hành được như là mã lệnh của JS

Math.PI : hằng số PI = 3.14

Math.sqrt(a) : căn bậc 2 của a

Math.pow(x,y) : tính xy

Math.random() : tạo số ngẫu nhiên >0 và <1

Math.abs (number) - Trả lại giá trị tuyệt đối của number

Math.acos (number) - Trả lại giá trị arc cosine (theo radian) của number Giá trị của number phải nămg giữa -1 và 1

Trang 24

Math.ceil (number) - Trả lại số nguyên nhỏ nhất lớn hơn hoặc bằng number.

Math.cos (number) - Trả lại giá trị cosine của number

Math.exp (number) - Trả lại giá trị e^ number, với e là hằng số Euler

Math.floor (number) - Trả lại số nguyên lớn nhất nhỏ hơn hoặc bằng number

Math.log (number) - Trả lại logarit tự nhiên của number

Math.max (num1,num2) - Trả lại giá trị lớn nhất giữa num1 và num2

Math.min (num1,num2) - Trả lại giá trị nhỏ nhất giữa num1 và num2

Math.pos (base,exponent) - Trả lại giá trị base luỹ thừa exponent

Math.random (r) - Trả lại một số ngẫu nhiên giữa 0 và 1 Phwong thức này chỉ thực hiện được trên nền tảng UNIX

Math.round (number) - Trả lại giá trị của number làm tròn tới số nguyên gầnnhất

Math.sin (number) - Trả lại sin của number

Math.sqrt (number) - Trả lại căn bậc 2 của number

Math.tan (number) - Trả lại tag của number

3.Xử lý chuỗi(String)

Length :Trả về độ dài chuỗi

Split :Hàm này biến chuỗi thành mảng, hàm này nhận vào một tham số,

đó là ký tự hoặc nhóm ký tự phân tách các phần tử trong chuỗi

Ngày đăng: 06/05/2014, 13:54

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w