Windows Child Object In DHTML

The window object also has child objects, which contain related information about the browser. Commonly-used child objects include:
 
• Navigator
• History
• Location
 
The navigator object
 
This object holds all the information about the type of browser and system the user is using. The navigator object has read-only properties.
 
<HTML>

<HEAD>

<TITLE>Navigator</TITLE>

<SCRIPT>

function navigatorProperties()

{

	msg='';

	for (p in navigator)

	msg+=p+' : '+navigator[p]+'\n';



	//alert(msg);

	document.f1.t1.value=msg;

}

</SCRIPT>

</HEAD>

<BODY onload="javascript:navigatorProperties();">

<h1 style="color:#99CCFF;">
List of <u>'navigator'</u> properties</h1>

<hr color=blue>

<FORM  name="f1">

	<TEXTAREA id="t1" NAME="t1" ROWS="20" COLS="50" disabled="true">
</TEXTAREA>

</FORM>	

</BODY>

</HTML> 

(See example.) Different systems and setups produce different results.
 
The history object
 
When you are surfing the net, you often use the back and forward buttons to go back to a page you have already visited. The history object allows us to travel forwards and backwards in script. The use of the history object is straightforward.
 
history.back();
 
sends us back one page
 
history.forward();
 
We can also use
 
history.go(n);
 
which sends us forward n pages (n>0), or back n pages (n<0).
 
The location object
 
The location holds detailed information about the current URL. Replace all instances of navigator with location in the navigator example to see a list of properties and their values of the location object.
 
Source code:
<HTML>

<HEAD>

<TITLE>location</TITLE>

<SCRIPT>

function locationProperties()

{

	msg='';

	for (p in location)

	msg+=p+' : '+location[p]+'\n';



	//alert(msg);

	document.f1.t1.value=msg;

}

</SCRIPT>

</HEAD>

<BODY onload="javascript:locationProperties();">

<h1 style="color:#99CCFF;">List of <u>'location'</u> properties</h1>

<hr color=blue>

<FORM  name="f1">

	<TEXTAREA id="t1" NAME="t1" ROWS="20" COLS="50" disabled="true"><
/TEXTAREA>

</FORM>

	

</BODY>

</HTML>
Scroll to Top