In this lesson are presented the JavaScript level one browser objects: navigator and history.

1. navigator object

The navigator object gives some informations about what browser is running your code.
You can use it to collect data about what browsers visit your sites. For example, if you know that Internet Explorer doesn’t support some code, you can test:
      if ( window.navigator.appName == "Microsoft Internet Explorer" ).

navigator object properties


- The following example writes in the page the return values of these properties (used on Firefox).
<script type="text/javascript"><!--
document.write('appCodeName - '+ navigator.appCodeName+ '<br />');
document.write('appName - '+ navigator.appName+ '<br />');
document.write('appVersion - '+ navigator.appVersion+ '<br />');
document.write('cookieEnabled - '+ navigator.cookieEnabled+ '<br />');
document.write('platform - '+ navigator.platform+ '<br />');
document.write('userAgent - '+ navigator.userAgent+ '<br />');
--></script>
- The result is:
appCodeName - Mozilla
appName - Netscape
appVersion - 5.0 (Windows; en-US)
cookieEnabled - true
platform - Win32
userAgent - Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13

navigator object methods


- The following example writes a message about if Java is enabled or not.
<script type="text/javascript"><!--
if (navigator.javaEnabled) document.write('Java enabled');
else document.write('Java is not enabled');
--></script>

2. history object

The history object contains a list of URLs that the user visited within the current browser window and some features to navigate that list. It is part of the window object and is accessed through the window.history

history object properties

- Example:
<script type="text/javascript"><!--
document.write(window.history.length);      // 3
--></script>

history object methods


- The fallowing example creates a button to go back two pages:
<script type="text/javascript"><!--
function goBack() {
  window.history.go(-2);
}
--></script>
<button onclick="goBack()">Go Back 2</button>

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag defines the clickable areas inside the image map?
<map> <img> <area>
<img src="image.jpg" usemap="#map1">
<map name="map1">
  <area shape="rect" coords="9, 120, 56, 149" href="#">
  <area shape="rect" coords="100, 200, 156, 249" href="#">
</map>
Which CSS property defines what is done if the content in a box is too big for its defined space?
display overflow position
#id {
  overflow: auto;
}
Click on the event which is triggered when the mouse is positioned over an object.
onclick onmouseover onmouseout
document.getElementById("id").onmouseover = function(){
  document.write("Have Good Life");
}
Indicate the PHP variable that contains data added in URL address after the "?" character.
$_SESSION $_GET $_POST
if(isset($_GET["id"])) {
  echo $_GET["id"];
}
navigator and history objects

Last accessed pages

  1. Create simple Website with PHP (15204)
  2. Zuma Games (17987)
  3. Flash Games - Free online Games (16913)
  4. Table Tennis (413)
  5. Sport Games (7119)

Popular pages this month

  1. Qwop (6860)
  2. Drag Racer V3 (4691)
  3. Bubbles3 (1916)
  4. List with All the Games (1605)
  5. Butterfly Kyodai (1507)