Javascript Sem6 Bca
Javascript Sem6 Bca
All the standards JavaScript object have such properties placing a dot
after the object name can access a property of an object.
This is the top level object in the hierarchy of the browser object and is
automatically defined by the browser.
JavaScript assume that you are referring to the current window object
and execute the following stmt.
Window.document.write (“tybca”)
All the data available to JavaScript about the browser is attached to the
window object as properties.
Various properties of the window object are:
1)closed:
It identifies whether window is closed.
2)default status:
default message that appears in the status bar of the browser.
3)frames:
An array that contains all frame object contained in the window.
4)location:
source location of the document in the window.
5)name:
the name of the window by which it is identified.
6)top:
it refers the topmost parent window.
7)open:
the object that caused the window to open.
8)status:
The status bar is the bar on the lower left side of the browser and
is used to display temporary message.
The window status bar will not always work when written to page load.
Normally it is used when event happens such as when the user clicks on
something or moves the mouse over an item.
Window Object Methods:
1)alert:
displays an alert dialog box. The alert function is displayed
message in dialog box.
2)focus:
this function will give focus to the window.
3)blur:
this function removes the focus from the window.
4)confirm(“msg”):
The string passed to the confirm function is displayed in the
confirm dialogs box.
The dialog box returns a true or false value depending on which button
was clicked.
5)prompt(“msg” “defaultsmsg”):
A prompt dialog box is displayed with the message
passed as the prompt question or phrase.
If no default message string is present no default string is displayed.
The history object represent the list of document that the current window
has displayed.
The history object does not allow the user to actually see the URL that
have been displayed previously in the browser.
It provide methods that allows the user to navigate back and forth
through the list of previous pages.
Ex: window.history.back()
Or
history. back()
The above stmt has the same effect as pressing the back button of the
browser once.
JavaScript Location Object:
The location object is the part of the window object and is accessed
through the window. Location property.
Location object properties:
1)Hash:
sets the URL from the hash sign.
2)Host:
set or return the host name and port name of the current URL.
3)Hostname:
set or return the hostname of current URL.
4)Href:
set or return the entire URL.
5)pathname:
set or return the path of current URL.
6)port:
set or return the port number of the current URL
7)protocol:
set or return the protocol of the current URL.
The most frequently used property is href which is used to display a
new document in the current window.
Ex:
window.location.href=<<http://
or
location.href=<<http://
These properties will work if the file being display was fetched from
web server.
Location Object methods:
1)assign():
It simply loads a new document.
2)reload():
It reloads the current document.
3)replace():
It replaces the current document with a new one.
JavaScript Screen Object:
1) avilHeight:
Return the height of the displayed screen (excluding the windows
taskbar)
2) avilwidth:
Returns the width of the displayed screen.
3) colordepth:
Return the bit depth of the color palette on the destination device.
4) deviceXDPI:
It return the number of horizontal dots per inches of the
displayed screen
5) deviceYDPI:
It return the number of vertical dots per inches of the displayed
screen.
6)height:
The height of the displayed screen
7) PixelDepth:
It returns the color resolution of the displayed screen.
8)width:
It returns the width of the displayed screen.
9) LogicalXDPI:
It returns the normal number of horizontal dots per inch of the
displayed screen.
JavaScript Navigator Object:
Navigator properties:
1) appcodeNames:
The name of the browsers code i.e. Mozilla
2) appMinorVersion:
The minor version number of the browser.
3) appName:
The name of the browser i.e Netscape.
4) cookie Enabled:
A Boolean value of true or false depending on whether cookies
are enabled in the browser.
5) UserLangauge:
the language the user using such as “en-us”
6) plugins:
An array of all plug-ins installed in the browser.
A plug-ins is a special helper application, which browser uses to
integrate multimedia.
7) mimetypes:
An array of all mime type currently supported by the browser.
An mime type specifies how information is encoded for plug-in to use.
MIME provides away to exchange file in any format between computer
using mail.
Navigator methods:
1) javaEnabled():
Returns a Boolean if the browser has JavaScript enabled.
2) taintEnabled():
1) escape(string):
It encode a string from ASCII into ISO Latin-1 character set which is
suitable for HTML processing.
It passed the string to be encoded and return the encoded string.
2) unescape():
It convert an ISO 8859-1 character set to ASCII.
Ex:
If a string is “MY PHONE # IS 123” after escape function it is
MY%20PHONE%20%23%20 is%20123
after unscape it is “MY PHONE # IS 123”
3) eval():
4) isNan(value):
If the value passed is not a number then boolean value of true is
returned.
If it is number it return false.
.5) parseFloat ():
6) parseInt ():
Events represents the entire activity that goes between the program
system and the user.
1) abort ():
It occurs when the user cancels loading of an image.
2) blur ():
It occurs when focus is removed from window.
3) click ():
It occurs when user clicks on a link.
4) change ():
It occurs when an error happens during loading of a document or
image
5) error () :
It occurs when an error happens during loading of a document.
6) load ():
It occurs when a page is loaded into explorer.
7) mouseout ():
It occurs when the user moves the pointer of a link.
8) mouseover ():
It occurs when the user moves the pointer over a hypertext link.
9) reset ():
It occurs when the user clears a form using the reset button.