• Tidak ada hasil yang ditemukan

JavaScript

N/A
N/A
Protected

Academic year: 2025

Membagikan "JavaScript"

Copied!
22
0
0

Teks penuh

(1)

JavaScript JavaScript

Mr.Jestin James M

Asst.Professor, Department of Computer Science L.F College Guruvayoor

(2)

Origins of JavaScript Origins of JavaScript

Developed by Brenden Eich

First name mocha

Renamed to livescript

Official name when it was released in

Official name when it was released in 1995

Later it became Javascript

Standardised by ECMA(European

Computer Manufactures Association)

(3)

Including Scripts in Web pages Including Scripts in Web pages

Using <script> tag

<script language= “JavaScript”>

</script>

But we should use for standard format But we should use for standard format

<script type=“text/JavaScript”>

</script>

(4)

Including Scripts in Web pages Including Scripts in Web pages continue

continue

1. In the <head> of a page

2. In The <body> section

3. In External life

(5)

3. In external life 3. In external life

When you use script in more than one page

<script type= “JavaScript”

src=“Scripts/validation.js”/>

src=“Scripts/validation.js”/>

(6)

Script hiding Script hiding

<script type=“text/javascript”>

<!- -

Put your JavaScript here //-->

//-->

(7)

<

<noscript noscript> element > element

Javascript aware browsers should ignore the content of <noscript> element

Browsers that are not JavaScript aware will show the enclosed message

will show the enclosed message

(8)

Document Object Model(DOM) Document Object Model(DOM)

It is a cross platform and language independent API

It is a Web standard defined by W3C

It provides methods for retrieving and

It provides methods for retrieving and setting the properties of objects.

Creating dynamic contents

DOM defines the logical structure of documents and the way a document is accessed and manipulated

(9)

DOM DOM

DOM is separated into 3 parts

Core, HTML, XML

Core : a low level set of objects that can represent any structured document

represent any structured document

HTML and XML specifications provide additional, higher-level interfaces that are used with the core specification to

provide a more convenient view into the document

(10)

DOM object Hierarchy DOM object Hierarchy

Window object

Location

object History

object Document

object Navigator Object Screen

Object

Anchor

object Applet

Object Area

Object Form

Object

Button

Object Check Box

object File Upload Object

Hidden

Object Option

Object Passwor

d Object

Radio

Object Radio

Object Select

Object Submit

Object Text

Object

Text Area Object Image

Object Link

Object

(11)

Window Object Window Object

It represents the browsers frame or window

It includes number of properties

What browser is running

What browser is running

Pages the user has visited

Size of browser window

Size of users screen

(12)

To access and change the text in the browsers status bar

Change the page that is loaded

(13)

Window object Window object

Window is the global object

window.alert(“hello”);

To change the status bar

<script type=“text/JavaScript”>

<script type=“text/JavaScript”>

Window.defaultstatus= “Hello”;

</script>

(14)

History Object History Object

It keeps track of each page the user visits

The list of pages is commonly called History stack

Length property- How many pages are in

Length property- How many pages are in the history stack

Back( ) and forward( ) methods

Another method is go( )- one parameter

history.go(-2) or history.go(3) go(-1) = back & go(1)=forward

(15)

Location object Location object

It contains the information about the current pages location

URL, server hosting page, port number of server location and protocol used

server location and protocol used

These are available through location object`s href, host name, port, and protocol properties

(16)

Location object Location object

For navigating 2 methods

Use href property or replace( ) method

The replace( ) method removes the current page from history stack

current page from history stack

href property adds the new page into the history stack

window.location.replace(“mypage.html”);

window.location.href= mypage.html”

(17)

Navigator Object Navigator Object

The better name will be browser object

It contains the information about the

browser and the OS in which it is running

(18)

Screen Object Screen Object

Display capabilities of the client machine

It properties include height and width properties –which indicates the vertical and horizontal range of the screen in

and horizontal range of the screen in pixels

Colordepth property This tells you the number of bits used for colors on the clients screen

(19)

Document object Document object

Most important object

Forms collection contains all the <form> tags

Image collection represents all the image in a document

document

The link collection represents all the hyperlink within a page

The anchor collection represents all the anchors in the document

The area collection represents all the image

maps that use an area element in the document

(20)

Document object Document object

Form has button,chkbox,radiobutton etc…

Page no:161

Document.links[0].href

Document.links[0].href

Document – we are accessing the document object

Link- it indicates links collection

The[0 ] indicates we want first link in the document

(21)

Document object Document object

Href- we want href property

Alternative method

Document.frmlogin.frmpassword.value

(22)

Objects, Methods, and Properties Objects, Methods, and Properties

The document object model is made up of several objects that represents

different part of the document.

Each object can have properties and

Each object can have properties and methods

Property tells you something about an object

Method perform an action

Referensi

Dokumen terkait

menyatakan bahwa Skripsi yang berjudul “RANCANG BANGUN DOMINATEMYJS UNTUK PEMBELAJARAN JAVASCRIPT HTML DOCUMENT OBJECT MODEL MENGGUNAKAN METODE GAMIFIKASI

• DOM (Document Object Model), hasil proses yang diterima akan kita tampilkan dengan memanipulasi objek DOM yang telah kita persiapkan sebelumnya

In this research work, we propose an improved model namely wrapper extraction of image using document object model (DOM) and JavaScript object notation data

Aplikasi web ini menggunakan bahasa pemrograman Hypertext Preprocessor (PHP), MySQL untuk databasenya dan fungsi DOM(Document Object Model)XML yang terdapat dalam PHP untuk membuat

The Macro Recorder has been a part of Excel for quite a long time, and it’s still the best way to get a look at some of the objects that make up the Excel Document Object Model

Accessing some dialog boxes when double-clicking a tool in the InDesign Toolbox requires you first to select an object in the document window. Selection/Direct Selection tools: The

Yang mana entitas data tersebut akan ditampilkan pada browser menggunakan JavaScript dan DOM (Document Object Model) untuk memanipulasi object atau bagian dari halaman

HTMLHTML css css js js  DANH SÁCH CHIA NHÓM DOM:  DOM document: có nhiệm vụ lưu trữ toàn bộ các thành phần trong tài liệu của website  DOM element: có nhiệm vụ truy xuất tới thẻ