Active Client Pages: More Questions and Answers on Chrys`s Approach
This is the third part of my series, "Active Client Pages: Chrys’s Approach." We continue to learn the roots that give rise to my approach to Active Client Pages. We will also answer more questions about the technique and its capabilities.
Active Client Pages: More Questions and Answers on Chrys`s Approach - Can you create your own Back and Forward buttons? (Page 3 of 4 )
When you load (create) a document at the client, the browser is supposed to enable the Back and Forward buttons accordingly. Some browsers may not do this. So the question is, can you create your own on each web page? Yes you can. You need to use the DOM History Object. The property and methods of this object are as follows:
History Object Properties
Property
Description
length
Returns the number of elements in the history list
History Object Methods
Method
Description
back()
Loads the previous URL in the history list
forward()
Loads the next URL in the history list
go()
Loads a specific page in the history list
The DOM length Property
Definition and Usage
The length property returns the number of elements in the history list.
Syntax
history.length
Example
<html>
<body><script type="text/javascript">
document.write(history.length);
</script></body>
</html>
If you try the above code in your home computer, the answer will be zero.
The DOM back() Method
Definition and Usage
The back() method loads the previous URL in the history list.
This is the same as clicking the Back button or history.go(-1) (see later).
Syntax
history.back()
Example
The following example creates a back button on a page: