1. Trang chủ
  2. » Mẫu Slide

slide môn học HDJ bài 9 the browser objects in javascript

25 146 0

Đ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

Định dạng
Số trang 25
Dung lượng 253,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

Web Page Programming with HTML,DHTML & JavaScript/Session 9/ 3 of 21 Event Object - Concept  Events are a result of an action done by the user  An event may be user-generated or genera

Trang 1

The Browser Objects in JavaScript

Session 9

Trang 2

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 2 of 21

Objectives

Trang 3

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 3 of 21

Event Object - Concept

Events are a result of an action done by the user

An event may be user-generated or generated by the system

Each event has an associated event object The event object provides information on:

the type of event

the location of the cursor at the time of the event

The event object is used as a part of an event handler

Trang 4

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 4 of 21

Event – Life Cycle

returns

Trang 5

Web Page Programming with HTML,DHTML &

Trang 6

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 6 of 21

Handling the Events

 This segment of JavaScript code that will be executed in response to the event is called an event handler

<INPUT TYPE="button"

NAME="docode"

onClick="DoOnClick();">

 Event Handler are categorized as:

 Event handlers for HTML tags

<TAG eventHandler="JavaScript Code">

 Event Handlers as Properties

object.eventhandler = function;

Trang 7

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 7 of 21

onClick - Example

 The onClick event is generated whenever the user clicks the mouse button on certain form elements or on a hypertext link

Trang 8

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 8 of 21

onClick - Output

Trang 9

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 9 of 21

onChange - Example

 The onChange event occurs whenever a form element changes This can happen whenever the contents of a text control changes, or when a selection in a selection list changes

} // end hiding from old browsers >

</SCRIPT>

</HEAD>

<BODY bgColor = white>

<FORM>

Please enter a number:

<INPUT type = text size = 5 onChange="checkNum(this.value)">

</FORM>

</BODY>

</HTML>

Trang 10

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 10 of 21

onChange - Output

Trang 11

Web Page Programming with HTML,DHTML &

 The onMouseOut event is generated whenever the mouse cursor

moves off of an element

Trang 12

Web Page Programming with HTML,DHTML &

Trang 13

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 13 of 21

onMouseOut -Output

On moving the mouse over Aptech, the following output

is displayed

Trang 14

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 14 of 21

onLoad - onSubmit onMouseDown - onMouseUp

Trang 15

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 15 of 21

onResize - Example

 This event is activated when a resize event occurs That is,

when a user or script resizes a window or frame

Trang 16

Web Page Programming with HTML,DHTML &

Trang 17

Web Page Programming with HTML,DHTML &

 An object can be defined as a single entity, consisting of

Properties and Methods

 A property is a value that belongs to an object

Eg: Document.bgcolor

Trang 18

Web Page Programming with HTML,DHTML &

Trang 19

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 19 of 21

Window Object

Attribute Value Description (IE)

toolbar Boolean Back , Forward, other buttons in that row, and Address

field, displaying the current URL location Boolean N/A (always defaults to the value of toolbar)

status Boolean Status bar at the bottom of the window

menubar Boolean Menu bar at the top of the window (File, Edit, View, Go,

etc.) scrollbars Boolean N/A (always defaults to “yes”)

resizable Boolean N/A (always defaults to “yes”)

width Pixels Window’s width in pixels

height Pixels Window’s height in pixels

Trang 21

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 21 of 21

Document Object

 It represents the HTML document in a given browser window

and is used to retrieve information about the document

Trang 22

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 22 of 21

History Object

 This object provides a list of the URL's most recently

visited by the client

 Example, history's "back()" method cause the

window to again display the immediately previous

Trang 23

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 23 of 21

Location Object

 This object maintains information about the current URL It

provides a method that causes the window's current URL to be

Trang 24

Web Page Programming with HTML,DHTML &

JavaScript/Session 9/ 24 of 21

Navigator Object

 The navigator object does not belong to JavaScript’s bulk of browser objects It is an independent object, just like the Math object This object combines various methods and properties providing information related to the user’s software

 For example, you can use this object to detect the user’s browser, platform, plug-ins, and many other essential pieces of information.

Trang 25

Web Page Programming with HTML,DHTML &

Ngày đăng: 30/11/2016, 22:10

TỪ KHÓA LIÊN QUAN