By: aathishankaran in Javascript Tutorials on 2007年03月21日 [フレーム]
A long-time feature in browser software is the capability to track where you have surfed within a given session. This feature has come to .be known as a history list, and it's available in both the Navigator and Internet Explorer's Go menus. The history object is the JavaScript equivalent to this list. You can work with it as a user might, moving forward or backward in a list to navigate where a user has been.
Suppose you wanted to go back two pages in your history list when the user clicked a button. The event handler follows:
function goBackTwoPages()
{
window. history. go (-2)
}
Although the window object is the top-level object in the hierarchy, the document object is arguably the most important. The document object is responsible for all the actual content displayed on a given page. You can work with the document object to display dynamic HTML pages. Also contained within the document are all the typical user inter-face (UI) elements of a Web application.
A common use of the document object is generating HTML pages through JavaScript. You can do this with the write () or writeln() methods. For example the following code displays the HTML text specified as the method parameter:
<HTML>
<HEAD>
<SCRIPT>
document.write("<hl>Text created by JavaScript</hl>");
</SCRIPT>
</HEAD>
</HTML>
Forms give life to static pages by providing an interface users can interact with through controls. You can only place a button, text, or other UI object within the confines of a form. The form object is your means of inter-acting with this HTML element in your scripts.
Button Objects (Button, Submit, and Reset)
Unless you jumped into Web development from a character-based environment, you are undoubtedly familiar with push buttons. JavaScript has three button objects: button, submit, and reset. Each of these are the object representation of an HTML tag. The button object is a generic button that you need to add code to for it to be useful. The submit button is a specialized version of a button whose default action is to submit the form of which it is a part. Similarly, the reset button is hard coded to reset the values of all controls within a form. Yes, you could use a button object to serve the same role as the submit object (by calling the form's submit () method).
Another common control in windowed environments is a drop-down list or selection list box, both of which allow a user to select from a predefined list of values. The difference is that the user can select only one value from a drop-down list, whereas he can select multiple choices from a selection list. The select object encapsulates the behavior of both of these UI elements. In other words, it can appear as a drop-down list (default) or a selection list (if its multiple property is set to true).
Another industry-wide standard UI control is the checkbox. This element allows the user to specify a yes/no or true/false value by clicking the checkbox control.
Radio Object
Radio buttons are a set of mutually exclusive controls, such that if one radio button is selected, all other buttons in the set become unselected. The radio object provides this element in an HTML form. You define a set of radio buttons by giving them the same name property.
A principle element for any data entry application is a field in which the user can input data. The text object serves as this data-capturing device as the objectified representation of the text input HTML tag.
Related to the text object is the textarea object, which allows you to enter multiple lines of text as opposed to a single line.
The only difference between the text and password is that all the characters entered into the password object are displayed as asterisks.
Another field object, the hidden object is like a text object with a visible property set to false. It is used to store values to pass on to a server process. The hidden object comes from the pre-JavaScript days of HTML in which there were no such things as variables, arrays, or objects to store values. Although you might still want to employ them for transferring data among pages of a multiple-page data entry application, much of the data storage value of hidden objects is no longer needed with JavaScript.
The link object lets you work with links in JavaScript code, the link still remains the very heart of Web technology. Because a link is simply referencing another HTML page or other destination, it is very similar to the location object which contains the same information for the current HTML page.
The anchor object is a piece of text or an image in the HTML page that can be the target of a hypertext link. In practical terms, you use the anchor object very little with JavaScript, making it perhaps the least important of all built-in objects.
The image object is an encapsulation of an HTML image. Perhaps the most effective use of this object type is to cache images you want to display. You can construct an image object in your code and download the image data from the server before it is needed for display by the browser. When the image is requested, you can pull the image from cache rather than from the server.
The navigator object is an object rep-resenting the browser software in use.
Using this object, you can retrieve information about the name and version of the browser in use. Both Netscape Navigator and Microsoft Internet Explorer support the navigator object.
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in Javascript )
Dynamically modify the option set in Dynamics 365 forms
promise and .then() in JavaScript
reduce() and filter() in JavaScript
History and evolution of Javascript
Using parseInt() and parseFloat() in JavaScript to convert data types to Numbers
Show how many characters remaining in a html text box using javascript
Latest Articles (in Javascript)
© 2023 Java-samples.com
Tutorial Archive: Data Science React Native Android AJAX ASP.net C C++ C# Cocoa Cloud Computing EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Trends WebServices XML Office 365 Hibernate
Latest Tutorials on: Data Science React Native Android AJAX ASP.net C Cocoa C++ C# EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Cloud Computing WebServices XML Office 365 Hibernate