Showing posts with label ECMAScript. Show all posts
Showing posts with label ECMAScript. Show all posts

Thursday, April 4, 2013

Javascript Image Object Methods


The Image object represents an embedded image.

Image Object Properties
Align Sets or returns how to align an image according to the surrounding text
Alt Sets or returns an alternate text to be displayed, if a browser cannot show an image
Border Sets or returns the border around an image
Complete Returns whether or not the browser has finished loading the image
Height Sets or returns the height of an image
Hspace Sets or returns the white space on the left and right side of the image
Id Sets or returns the id of the image
isMap Returns whether or not an image is a server-side image map
longDesc Sets or returns a URL to a document containing a description of the image
Lowsrc Sets or returns a URL to a low-resolution version of an image
Name Sets or returns the name of an image
Src Sets or returns the URL of an image
useMap Sets or returns the value of the usemap attribute of an client-side image map
Vspace Sets or returns the white space on the top and bottom of the image
Width Sets or returns the width of an image

Javascript Button Object Properties and Event Handlers

The Button object represents a push button.

Button Object Properties
accessKey Sets or returns the keyboard key to access a button
Disabled Sets or returns whether a button should be disabled
Form Returns a reference to the form that contains the button
Id Sets or returns the id of a button
Name Sets or returns the name of a button
tabIndex Sets or returns the tab order for a button
Type Returns the type of form element a button is
Value Sets or returns the text that is displayed on a button

Event Handlers
Onabort Loading of an image is interrupted
Onblur An element loses focus
Onchange The content of a field changes
Onclick Mouse clicks an object
Ondblclick Mouse double-clicks an object
Onerror An error occurs when loading a document or an image
Onfocus An element gets focus
Onkeydown A keyboard key is pressed
Onkeypress A keyboard key is pressed or held down
Onkeyup A keyboard key is released
Onload A page or an image is finished loading
Onmousedown A mouse button is pressed
Onmousemove The mouse is moved
Onmouseout The mouse is moved off an element
Onmouseover The mouse is moved over an element
Onmouseup A mouse button is released
Onreset The reset button is clicked
Onresize A window or frame is resized
Onselect Text is selected
Onsubmit The submit button is clicked
Onunload The user exits the page

Javascript Methods on Document Object


The Document object represents the entire HTML document and can be used to access all elements in a page.

Document Object Collections
anchors[] Returns a reference to all Anchor objects in the document
forms[] Returns a reference to all Form objects in the document
images[] Returns a reference to all Image objects in the document
links[] Returns a reference to all Area and Link objects in the document

Document Object Properties
Body Gives direct access to the <body> element
Cookie Sets or returns all cookies associated with the current document
Domain Returns the domain name for the current document
lastModified Returns the date and time a document was last modified
Referrer Returns the URL of the document that loaded the current document
Title Returns the title of the current document
URL Returns the URL of the current document

Document Object Methods
close() Closes an output stream opened with the document.open() method
getElementById() Returns a reference to the first object with the specified id
getElementsByName() Returns a collection of objects with the specified name
getElementsByTagName() Returns a collection of objects with the specified tagname
open() Opens a stream to collect the output from any document.write() or document.writeln()
write() Writes HTML expressions or JavaScript code to a document
writeln() Identical to the write(), with the addition of writing a new line character after expression

Javascript Screen Object Properties


The Screen object is actually a JavaScript object, not an HTML DOM object..

Screen Object Properties
availHeight Returns the height of the display screen (excluding the Windows Taskbar)
availWidth Returns the width of the display screen (excluding the Windows Taskbar)
bufferDepth Sets or returns the bit depth of the color palette in the off-screen bitmap buffer
colorDepth Returns the bit depth of the color palette on the destination device or buffer
deviceXDPI Returns the number of horizontal dots per inch of the display screen
deviceYDPI Returns the number of vertical dots per inch of the display screen
fontSmoothingEnabledReturns whether the user has enabled font smoothing in the display control panel
Height The height of the display screen
logicalXDPI Returns the normal number of horizontal dots per inch of the display screen
logicalYDPI Returns the normal number of vertical dots per inch of the display screen
pixelDepth Returns the color resolution (in bits per pixel) of the display screen
updateInterval Sets or returns the update interval for the screen
Width Returns width of the display screen

Javascript functions on Windows Object


The Window object is the top level object in the JavaScript hierarchy.

Window Object Collections
frames[] Returns all named frames in the window
Closed Returns whether or not a window has been closed
defaultStatus Sets or returns the default text in the statusbar of the window
Document See Document object
history
Length Sets or returns the number of frames in the window
Location
Name Sets or returns the name of the window
Opener Returns a reference to the window that created the window
outerHeight Sets or returns the outer height of a window
outerWidth Sets or returns the outer width of a window
pageXOffset Sets or returns the X position of the current page in relation to the upper left corner
pageYOffset Sets or returns the Y position of the current page in relation to the upper left corner
Parent Returns the parent window
Personalbar Sets whether or not the browser's personal bar (or directories bar) should be visible
Scrollbars Sets whether or not the scrollbars should be visible
Self Returns a reference to the current window
Status Sets the text in the statusbar of a window
Statusbar Sets whether or not the browser's statusbar should be visible
Toolbar Sets whether or not the browser's tool bar is visible or not
Top Returns the topmost ancestor window

Window Object Methods
alert() Displays an alert box with a message and an OK button
blur() Removes focus from the current window
clearInterval() Cancels a timeout set with setInterval()
clearTimeout() Cancels a timeout set with setTimeout()
close() Closes the current window
confirm() Displays a dialog box with a message and an OK and a Cancel button
createPopup() Creates a pop-up window
focus() Sets focus to the current window
moveBy() Moves a window relative to its current position
moveTo() Moves a window to the specified position
open() Opens a new browser window
print() Prints the contents of the current window
prompt() Displays a dialog box that prompts the user for input
resizeBy() Resizes a window by the specified pixels
resizeTo() Resizes a window to the specified width and height
scrollBy() Scrolls the content by the specified number of pixels
scrollTo() Scrolls the content to the specified coordinates
setInterval() Evaluates an expression at specified intervals
setTimeout() Evaluates an expression after a specified number of milliseconds

Javascript function on Number Object


The Number object is an object wrapper for primitive numeric values.

Syntax for creating a Number object: var myNum=new Number(number);

Number Object Properties
Constructor Returns a reference to the Number function that created the object
MAX_VALUE Returns the largest possible value in JavaScript
MIN_VALUE Returns the smallest possible value in JavaScript
NaN Represents "Not-a-number" value
NEGATIVE_INFINITY Represents a value that is less than MIN_VALUE
POSITIVE_INFINITY Represents a value that is greater than MAX_VALUE
Prototype Allows you to add properties and methods to the object

Number Object Methods
toExponential() Converts the value of the object into an exponential notation
toFixed() Formats a number to the specified number of decimals
toLocaleString()
toPrecision() Converts a number into a number with a specified number of digits
toString() Converts the Number object into a string
valueOf() Returns the value of the Number object

Javascript Functions on Math Object


The Math object allows you to perform mathematical tasks.

Syntax for using properties/methods of Math:
var pi_value=Math.PI; var
sqrt_value=Math.sqrt(16);

Math Object Properties
E Returns Euler's constant (approx. 2.718)
Ln2 Returns the natural logarithm of 2 (approx. 0.693)
Ln10 Returns the natural logarithm of 10 (approx. 2.302)
LOG2E Returns the base-2 logarithm of E (approx. 1.442)
LOG10E Returns the base-10 logarithm of E (approx. 0.434)
PI Returns PI (approx. 3.14159)
SQRT1_2 Returns the square root of 1/2 (approx. 0.707)
SQRT2 Returns the square root of 2 (approx. 1.414)



abs(x) Returns the absolute value of a number
acos(x) Returns the arccosine of a number
asin(x) Returns the arcsine of a number
atan(x) Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians
atan2(y,x) Returns the angle theta of an (x,y) point as a numeric value between -PI and PI radians
ceil(x) Returns the value of a number rounded upwards to the nearest integer
cos(x) Returns the cosine of a number
exp(x) Returns the value of Ex
floor(x) Returns the value of a number rounded downwards to the nearest integer
log(x) Returns the natural logarithm (base E) of a number
max(x,y) Returns the number with the highest value of x and y
min(x,y) Returns the number with the lowest value of x and y
pow(x,y) Returns the value of x to the power of y
random() Returns a random number between 0 and 1
round(x) Rounds a number to the nearest integer
sin(x) Returns the sine of a number
sqrt(x) Returns the square root of a number
tan(x) Returns the tangent of an angle
toSource() Represents the source code of an object
valueOf() Returns the primitive value of a Math object

Javascript Functions on the Boolean Object


The Boolean object represents two values: "true" or "false".

Syntax for creating a Boolean object:
var myBool=new Boolean(value)

Boolean Object Properties
Constructor Returns a reference to the Boolean function that created the object
Prototype Allows you to add properties and methods to the object

Boolean Object Methods
toSource() Returns the source code of the object
toString() Converts a Boolean value to a string and returns the result
valueOf() Returns the primitive value of a Boolean object

Javascript functions on the Array Object

The Array object is used to store multiple values in a single variable.


Syntax for creating an Array object:
var myCars=new Array("Saab","Volvo","BMW")

Array Object Properties
Constructor Returns a reference to the array function that created the object
index
input
Length Sets or returns the number of elements in an array
Prototype Allows you to add properties and methods to the object

Array Object Methods
Method
concat() Joins two or more arrays and returns the result
join() Puts all the elements of an array into a string. The elements are separated by a delimiter
pop() Removes and returns the last element of an array
push() Adds one or more elements to the end of an array and returns the new length
reverse() Reverses the order of the elements in an array
shift() Removes and returns the first element of an array
slice() Returns selected elements from an existing array
sort() Sorts the elements of an array
splice() Removes and adds new elements to an array
toSource() Represents the source code of an object
toString() Converts an array to a string and returns the result
unshift() Adds one or more elements to the beginning of an array and returns the new length
valueOf() Returns the primitive value of an Array object

javascript Functions on the Date Object


The Date object is used to work with dates and times.

Syntax for creating a Date object: 
var myDate=new Date()

Date Object Properties

Constructor Returns a reference to the Date function that created the object
Prototype Allows you to add properties and methods to the object

Date Object Methods
Date() Returns today's date and time
getDate() Returns the day of the month from a Date object (from 1-31)
getDay() Returns the day of the week from a Date object (from 0-6)
getFullYear() Returns the year, as a four-digit number, from a Date object
getHours() Returns the hour of a Date object (from 0-23)
getMilliseconds() Returns the milliseconds of a Date object (from 0-999)
getMinutes() Returns the minutes of a Date object (from 0-59)
getMonth() Returns the month from a Date object (from 0-11)
getSeconds() Returns the seconds of a Date object (from 0-59)
getTime() Returns the number of milliseconds since midnight Jan 1, 1970
getTimezoneOffset() Returns the difference in minutes between local time and Greenwich Mean Time (GMT)
getUTCDate() Returns the day of the month from a Date object according to universal time (from 1-31)
getUTCDay() Returns the day of the week from a Date object according to universal time (from 0-6)
getUTCMonth() Returns the month from a Date object according to universal time (from 0-11)
getUTCFullYear() Returns the four-digit year from a Date object according to universal time
getUTCHours() Returns the hour of a Date object according to universal time (from 0-23)
getUTCMinutes() Returns the minutes of a Date object according to universal time (from 0-59)
getUTCSeconds() Returns the seconds of a Date object according to universal time (from 0-59)
getUTCMilliseconds()Returns the milliseconds of a Date object according to universal time (from 0-999)
parse() Takes a date string and returns the number of milliseconds since midnight of January 1, 1970
setDate() Sets the day of the month in a Date object (from 1-31)
setFullYear() Sets the year in a Date object (four digits)
setHours() Sets the hour in a Date object (from 0-23)
setMilliseconds() Sets the milliseconds in a Date object (from 0-999)
setMinutes() Set the minutes in a Date object (from 0-59)
setMonth() Sets the month in a Date object (from 0-11)
setSeconds() Sets the seconds in a Date object (from 0-59)
setTime() Calculates time adding or subtracting a number of milliseconds from midnight January 1, 1970
setUTCDate() Sets the day of the month in a Date object according to universal time (from 1-31)
setUTCMonth() Sets the month in a Date object according to universal time (from 0-11)
setUTCFullYear() Sets the year in a Date object according to universal time (four digits)
setUTCHours() Sets the hour in a Date object according to universal time (from 0-23)
setUTCMinutes() Set the minutes in a Date object according to universal time (from 0-59)
setUTCSeconds() Set the seconds in a Date object according to universal time (from 0-59)
setUTCMilliseconds()Sets the milliseconds in a Date object according to universal time (from 0-999)
toDateString() Returns the date portion of a Date object in readable form
toGMTString() Converts a Date object, according to Greenwich time, to a string. Use toUTCString() instead !!
toLocaleDateString()Converts a Date object, according to local time, to a string and returns the date portion
toLocaleTimeString()Converts a Date object, according to local time, to a string and returns the time portion
toLocaleString() Converts a Date object, according to local time, to a string
toSource() Represents the source code of an object
toString() Converts a Date object to a string
toTimeString() Returns the time portion of a Date object in readable form
toUTCString() Converts a Date object, according to universal time, to a string
UTC() Takes a date and returns the number of milliseconds since midnight of January 1, 1970
valueOf() Returns the primitive value of a Date object

Javascript Functions On the String Object



The String object let's you work with text.

Syntax for creating a String object :  var myStr=new String(string);

String Object Properties
Constructor A reference to the function that created the object
Length Returns the number of characters in a string
Prototype Allows you to add properties and methods to the object

String Object Methods
anchor() :   Creates an HTML anchor
big() :   Displays a string in a big font
blink() :   Displays a blinking string
bold() :   Displays a string in bold
charAt() :   Returns the character at a specified position
charCodeAt() :   Returns the Unicode of the character at a specified position
concat() :   Joins two or more strings
fixed() :   Displays a string as teletype text
fontcolor() :   Displays a string in a specified color
fontsize() :   Displays a string in a specified size
fromCharCode() :   Takes the specified Unicode values and returns a string
indexOf() :   Returns the position of the first occurrence of a specified string value in a string
italics() :   Displays a string in italic
lastIndexOf() :   Returns the position of the last occurrence of a string value, searching backwards
link() :   Displays a string as a hyperlink
match() :   Searches for a specified value in a string
replace() :   Replaces some characters with some other characters in a string
search() :   Searches a string for a specified value
slice() :   Extracts a part of a string and returns the extracted part in a new string
small() :   Displays a string in a small font
split() :   Splits a string into an array of strings
strike() :   Displays a string with a strikethrough
sub() :   Displays a string as subscript
substr() :   Extracts a specified number of characters in a string, from a start index
substring() :   Extracts the characters in a string between two specified indices
sup() :   Displays a string as superscript
toLowerCase() :   Displays a string in lowercase letters
toUpperCase() :   Displays a string in uppercase letters
toSource() :   Represents the source code of an object
valueOf() :   Returns the primitive value of a String object