Download - Chapter 4 Java Script – Part2
![Page 1: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/1.jpg)
Chapter 4Java Script – Part2
![Page 2: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/2.jpg)
2
Location object
Properties href – whole path will be displayed.
ex: window.location.href ( see example 11) protocol – protocol will be returned pathname – display path without protocol search – after ? In location bar what ever the
command lines are passed that are displayed. Methods
replace() – to replace with new file reload() – to reload a file
ex: window.location.replace(“1.html”) ( see example 12)
![Page 3: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/3.jpg)
3
Example 11.html
<HTML>
<HEAD>
< TITLE>JavaScript</TITLE>
<script type="text/javascript>"
var loc = window.location.href;
document.write("Path=" +loc);
/<script>
/<HEAD>
<BODY>
/<BODY>
/<HTML>
![Page 4: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/4.jpg)
4
History object
Properties Length – to find the number of files in a history.
ex: window.history.length ( see example 13) Current – path of current file Previous – path of previous file Next – path of next file
Methods Back() – one file back Forward() – one file forward Go() – move multiple file
ex: window.history.go(-2)
![Page 5: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/5.jpg)
5
Example - 13.Html
<HTML><HEAD> <TITLE>Functions JavaScript</TITLE><script type="text/javascript"> var numberofvisited = window.history.length; document.write("The number of pages visited in this window
is" +numberofvisited+ " pages."+"<br>");
</script></HEAD>
<BODY >
</BODY></HTML>
![Page 6: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/6.jpg)
6
Document Object
Properties Images, links, anchors, forms, layers, applet, bgcolor,
text, background, link, alink,vlink etcex. Window.document.bgcolor
Methods write(), writeln(), open(), close() ex. window.document.open()
![Page 7: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/7.jpg)
7
Images Object
Images is an array object Properties
length, hspace, vspace, height, width, border etcex. window.document.images.length
Methods No methods
![Page 8: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/8.jpg)
8
Links Object
Links is an array object The Link object corresponds to a hypertext link
Properties length, href, protocol, pathname, search etc
ex. window.document.links.length
Methods No methods
![Page 9: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/9.jpg)
9
Anchors Object
The JavaScript anchor object describes a links destination or target.
Anchor is an array object Properties
name, text etc Methods
No methods
![Page 10: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/10.jpg)
10
Forms Object Forms is an array object Properties
action - This specifies the URL and CGI script file name the form is to be submitted to.
elements - An array of fields and elements in the form . encoding - It specifies the encoding method the form data
is encoded in before being submitted to the server. It corresponds to the ENCTYPE attribute of the FORM tag. The default is "application/x-www-form-urlencoded". Other encoding includes text/plain or multipart/form-data.
length - The number of fields in the elements array. I.E. the length of the elements array
method - This is a read or write string. It has the value "GET" or "POST".
name - The form name. Corresponds to the FORM Name attribute.
target - The name of the frame or window the form submission response is sent to by the server.
![Page 11: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/11.jpg)
11
Forms Object(Cont..) Form Objects
Button, text, password, file upload, radio, check box, text area, reset, select, submit etc.
Form Object Methods reset(), submit()
Events onReset, onSubmit
![Page 12: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/12.jpg)
12
Text Object
Properties Name, value, size, maxlength, readonly etc.
Methods focus(), blur(), select()
Events onFocus, onBlur, onSelect, onChange
Password Object same as Text Object
![Page 13: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/13.jpg)
13
Button, Submit, Reset Object
Properties Name, value etc.
Methods focus(), blur()
Events onFocus, onBlur, onClick, onMouseOver, onMouseOut
For checking the validations use an ordinary button and call a function.
For submitting the form data use the submit button
![Page 14: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/14.jpg)
14
Radio Object Properties
Name, value, check, length etc. Methods
focus(), blur() Events
onFocus, onBlur, onClick
Checkbox Object same as Radio Object
![Page 15: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/15.jpg)
15
Select Object Properties
Name, size, multiple, selectedIndex, options, length etc.
Methods focus(), blur(), select()
Events onFocus, onBlur, onClick, onChange
![Page 16: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/16.jpg)
16
Textarea Object Properties
rows, cols, name, value etc. Methods
focus(), blur() Events
onFocus, onBlur, onSelectex. window.document.formname.textarea.value
![Page 17: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/17.jpg)
17
File Object Properties
name, value, size etc. Methods
focus(), blur() Events
onFocus, onBlurex. window.document.formname.filename.value
![Page 18: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/18.jpg)
18
External ObjectsString, Array, Date, Math,
Navigator
String Object Properties
length etc. Methods
concat(), substr(), indexOf(), lastIndexOf(), reverse(), charAt(), split(), blink(), italic(), big(), small(), bold(), fontColor(), fontSize(), toUpperCase(), toLowerCase() etc
![Page 19: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/19.jpg)
19
Array Object Properties
index, input, length etc. Methods
pop(), push(), shift(), unshift(), concat(), chop(), splice() etc
![Page 20: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/20.jpg)
20
Date Object Properties
No properties. Methods
getDate(), getDay(), getMonth(), getYear(), getMinutes(), getSeconds(), getTime() etc
![Page 21: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/21.jpg)
21
Math Object Methods
sin(), cos(), tan(), round(), floor(), sqrt() etc
Navigator Object Properties
appName, appVersion, appCodeName etc
![Page 22: Chapter 4 Java Script – Part2](https://reader030.vdocuments.pub/reader030/viewer/2022032708/56812d3c550346895d924081/html5/thumbnails/22.jpg)
22
Frames Object
Frames is an array object (The Array object is used to store multiple values in a single variable)
Using the frames we can access a document object, history object, location object.
Properties src, name, cols, rows, border, scrolling, document,
location, history etcex. Window.framename.document.formname.text.value
Methods blur(), focus() etc