Books
in black and white
Main menu
Home About us Share a book
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

Javascript for dummies. Quick Reference - Vander

Vander Javascript for dummies. Quick Reference - Wiley Publishing, 2002. - 115 p.
Download (direct link): javascriptquickreference2002.pdf
Previous << 1 .. 34 35 36 37 38 39 < 40 > 41 42 43 44 45 46 .. 72 >> Next

Date.parse(dateString)
Example:
myBirthday.setTime(Date.parse("Jul 26, 1996"))
pout
Use the pow() method of the Math object to return a specified base to the specified exponent power.
Syntax:
Math.pow(base, exponent)
Example:
document.write("1 to the power of 8 is " +
Math.pow(7,8))
prompt
Use the prompt () method of the wi ndow object to display a pop-up dialog box that contains a message that you define, an input field, an OK button, and a Cancel button. The optional parameter inputDefault pre-fills the input field with the default value that you specify.
Syntax:
prompt("message" [, inputDefault])
Example:
promptC'What size t-shirt do you want?", "Large")
replace 11
random
Use the random() method of the Math object to return a random number between 0 and 1.
Syntax:
Math.random()
Example:
var aRandomNumber = Math.random()
reload
The г e 1 о a d () method of the location object forces a reload of the document specified by the URL in the href property of the location object. The result of the г e 1 о a d () method is the same as clicking on the Reload button in Navigator (or the Refresh button in Internet Explorer).
Syntax:
windowReference.1ocati on.reload()
Example:
<IN PUT TYPE="button" NAME="reloadButton"
VALUE="Reload Now" onClick=''self.location.reload()">
At the time of this writing, only Navigator 3.0 supports the rel oad () method.
replace
The r e p 1 a с e () method of the location object replaces the current history entry with the specified URL.
The upshot is that after JavaScript calls the repl ace () method, the new URL loads, and the user can no longer navigate to the previously loaded URL by clicking on the Back button.
Syntax:
windowReference.l ocati on.repl ace(" URL")
Example:
self.locati on.replace("http://home.netscape.com")
At the time of this writing, only Navigator 3.0 supports the
repl ace() method.
reset
reset
The reset() method of the form object simulates a user clicking on a Reset button; that is, it causes all a form’s elements to be reset to their default values.
Using the reset () method can make entering multiple copies of your form easier for users. When users finish filling out your form and submit it, you can call the reset () method to reset the form so they can fill it out again from scratch.
Syntax:
document.formName.reset()
Example:
if (resetOkay) {
document.my Form.reset О
}
At the time of this writing, only Navigator 3.0 supports the reset() method.
reverse
The reverseO method of the arrayobject transposes the elements of an array; that is, the order of the elements is reversed (the first element becomes the last and the last element becomes the first).
Syntax:
аггауНате.reverse()
Example:
var listOfJobs = new Array("bookie", "writer", "nurse") listOfJobs.reverseO
// Now the array is in this order: nurse, writer,
booki e
round
The round () method of the Math object returns the value of a specified number, rounded to the nearest integer.
Syntax:
Math.round(number)
Example:
var closeEnough = Math.round(totalPrice)
setOate
scroll
The scrol 1 () method of the wi ndow object lets you scroll a window to the coordinates you specify, scrol 1 () accepts two arguments: an x-coordinate and a у-coordinate. Both values must be integers representing the number of pixels to scroll in each direction (the x-coordinate is left-to-right, and the у-coordinate is up-and-down).
This method only executes if the page the method is on contains enough displayed data to be scrollable. Put another way, unless the page is so long that scroll bars are seen, calling scrol 1 () won’t have a visible effect.
Syntax:
wi ndowReference.scrol 1 {x-coordinate, y-coordinate) Example:
if(okayToScrol1) {
self.scrol1(50, 100)
}
At the time of this writing, only Navigator 3.0 supports the scrol 1 () method.
select
Use the sel ect() method of the password, text, or textarea objects to select (highlight) their respective input areas.
Syntax:
passwordName.se1 ect() textName.se1ect() textareaName. selectO
Example:
onBlur="document.my Form.myPass sword.select()" on Cl i с k=" document .my Form. myTextFi eld.selectO" if (goBackO) {
document.my Form.myTexta reaFi eld.select()
setbate
Use the s e t Da t e () method of the Date object to set the day of the month for a specified date. The required day Val ue parameter can be any integer from 1 to 31.
Syntax:
dateObjectName.setDateiday Value)
setHours
Example:
myBi rthday.setDate(26)
setHours
The setHours () method of the Date object enables you to set the hours for a specified date. The required hoursValue parameter can be any integer between 0 and 24. (For any value over 24, the interpreter adds the excess onto the days portion of the date.)
Syntax:
dateObjectName. setHours(hoursValue)
Example:
contractDate. setHours(12)
setMinutes
The setMinutesO method of the Date object enables you to set the minutes for a specified date. The required minutesValue parameter can be any integer between 0 and 60. (For any value over 60, the interpreter adds the excess onto the hours portion of the date.)
Previous << 1 .. 34 35 36 37 38 39 < 40 > 41 42 43 44 45 46 .. 72 >> Next