Document

download Document

of 24

description

Document

Transcript of Document

PowerPoint Presentation

Document objectDocument Object provides the foundation for creating dynamic web pages. The Document Object provides the ability for a JavaScript script to access, manipulate, and extend the content of a web page dynamically.The JavaScript Document object is the container for all HTML HEAD and BODY objects associated within the HTML tags of an HTML document. Which includes the properties of every form, link and anchor as well as global Document properties such as background and foreground colors.Document properties

PropertyDescriptionalinkcolorThe color to be used when displaying activated links in the documentAnchorsAn array of anchor objects present in the documentappletsAn array of Java Applet objects embedded into the documentbgColorThe background color of the documentfgColorThe foreground color (i.e., the color of the text in the document)CookieThe cookie, if any, assosiated with the document.domainThe current domain of the documentFormsAn array of the Forms objects contained in the document.ImagesAn Array of Image objects contained the documentlastModifiedThe date that the document was last modifiedlinkColorThe color to be used when displaying links in the documentlinksAn array of links contained in the documentDocument properties

PropertyDescriptiontitleThe title of the document (corresponds to the HTML tag)URLThe URL of the current documentvlinkColorThe color to be used when displaying links in the document whichhave been visited by the current userAnchors PropertyThis property is an array containing references to all the named Anchor objects in thecurrent document.Syntax:Document.anchorForms PropertyThis property is an array containing references to all the Form objects in the current documentSyntax: document.forms[formID]Links PropertyThis property is an array containing references to all the Area and Link objects in the currentdocument.Syntax: document.links[linkID]Cookie PropertyThis property is a string that returns a report detailing all visible and un-expired cookiesthat are associated with the specified document.Syntax:Document.cookieDomain PropertyThis property sets or returns the domain name of the server from which the documentoriginated.Syntax: document.domain = domaininfoTitle PropertyThis property returns the documents name as defined between the tags.Syntax: document.titleURL PropertyThis property is used to retrieve the documents full URL.Syntax: document.URLbgColor PropertyThis property defines a documents background color. The colorinfo argument is a stringthat can contain either the hexadecimal definition of the color or its literal description.Syntax: document.bgColor = colorinfofgColor PropertyThis property defines a documents foreground (text) color. The colorinfo argument is astring that can contain either the hexadecimal definition of the color or its literal description.Syntax: document.fgColor = colorinfoalinkColor PropertyThis property defines the color of an active link. The colorinfo argument is a string thatcan contain either the hexadecimal definition of the colour or its literal description.Syntax: document.alinkColor = colorinfovlinkColor PropertyThis property defines the colour of any visited links in the document. The colorinfoargument is a string that can contain either the hexadecimal definition of the color or itsliteral description.Syntax: document.vlinkColor = colorinfoDocument MethodsMethodDescription

open()Opens the output stream to the document for writingclose()Closes the output stream to the document to prevent further writingwrite()Appends text to the document.writeln()Appends text to the document followed by a newline charactergetElementByID()Accesses the first element with the specified idgetElementsByName()Accesses all elements with a specified namegetElementsByTagName()Accesses all elements with a specified tagnameOpen methodThe open() method opens a stream to collect the output from any document.write or document.writeln methods.NOTE: If a document already exists in the target, it will be cleared. If this method has no arguments, a new window with about:blank is displayed.Syntax:document.open(mimetype,replace)

Write methodThe write() method writes HTML expressions or JavaScript code to a document.Note: Multiple arguments (exp1,exp2,exp3,...) can be listed and they will be appended to thedocument in order of occurrence.Syntax:document.write(exp1,exp2,exp3,....)Writeln methodsThe writeln() method is identical to the write() method, with the addition of writing a new line character after each expression.Syntax:document.writeln(exp1,exp2,exp3,....)Close methodsThe close() method closes an output stream opened with the document.open method, anddisplays the collected data.Syntax:Document.close()Window objectWindow Object Properties

PropertyDescriptionclosedReturns a Boolean value indicating whether a window has been closed or notdefaultStatusSets or returns the default text in the statusbar of a windowdocumentReturns the Document object for the window framesReturns an array of all the frames (including iframes) in the current windowhistoryReturns the History object for the window innerHeightSets or returns the inner height of a window's content areainnerWidthSets or returns the inner width of a window's content arealengthReturns the number of frames (including iframes) in a windowlocationReturns the Location object for the window nameSets or returns the name of a windownavigatorReturns the Navigator object for the window openerReturns a reference to the window that created the windowouterHeightSets or returns the outer height of a window, including toolbars/scrollbarsouterWidthSets or returns the outer width of a window, including toolbars/scrollbarspageXOffsetReturns the pixels the current document has been scrolled (horizontally) from the upper left corner of the windowpageYOffsetReturns the pixels the current document has been scrolled (vertically) from the upper left corner of the windowparentReturns the parent window of the current windowscreenReturns the Screen object for the window screenLeftReturns the x coordinate of the window relative to the screenscreenTopReturns the y coordinate of the window relative to the screenscreenXReturns the x coordinate of the window relative to the screenscreenYReturns the y coordinate of the window relative to the screenselfReturns the current windowstatusSets the text in the statusbar of a windowtopReturns the topmost browser windowWindow Object Methods

MethodDescriptionalert()Displays an alert box with a message and an OK buttonblur()Removes focus from the current windowclearInterval()Clears a timer set with setInterval()clearTimeout()Clears a timer set with setTimeout()close()Closes the current windowconfirm()Displays a dialog box with a message and an OK and a Cancel buttoncreatePopup()Creates a pop-up windowfocus()Sets focus to the current windowmoveBy()Moves a window relative to its current positionmoveTo()Moves a window to the specified positionopen()Opens a new browser windowprint()Prints the content of the current windowprompt()Displays a dialog box that prompts the visitor for resizeBy()Resizes the window by the specified pixelsresizeTo()Resizes the window to the specified width and heightscroll()scrollBy()Scrolls the content by the specified number of pixelsscrollTo()Scrolls the content to the specified coordinatessetInterval()Calls a function or evaluates an expression at specified intervals (in milliseconds)setTimeout()Calls a function or evaluates an expression after a specified number of millisecondsWindow.locationwindow.location.href returns the href (URL) of the current pagewindow.location.hostname returns the domain name of the web hostwindow.location.pathname returns the path and filename of the current pagewindow.location.protocol returns the web protocol used (http:// or https://)window.location.assign loads a new document