Search notes:

Browser Object Model

anchors

console

The console object provides an API to a browser's debugging console (aka Web Console in Firefox).

document

See here.

forms

<!DOCTYPE html>
<html>
<head>

  <title>Form action</title>

  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

  <style type="text/css">
     
     .tall {
       height: 5000px
     }
  </style>

  <script type="text/javascript">

    function submit_pressed(one_two_or_three) {

      document.nameOfTheForm.action = "#target_" + one_two_or_three; 

      return true;
    }



  </script>

</head>
<body onload="init();">


   <h1 id="choose">Choose</h1>

   
    <form name="nameOfTheForm">

      <input type="submit" value="Target One"   onClick="return submit_pressed('one'  );"><br>
      <input type="submit" value="Target Two"   onClick="return submit_pressed('two'  );"><br>
      <input type="submit" value="Target Three" onClick="return submit_pressed('three');"><br>

    </form>

   <div class="tall"></div>

   
   <h1 id="target_one"  >Target one  </h1><a href='#choose'>Choose again</a><div class="tall"></div>
   <h1 id="target_two"  >Target two  </h1><a href='#choose'>Choose again</a><div class="tall"></div>
   <h1 id="target_three">Target three</h1><a href="#choose">Choose again</a><div class="tall"></div>

</body>
</html>

Github repository Browser-Object-Model, path: /forms/action.html

frames

history

<!DOCTYPE html>
<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  <title>history.length</title>

  <script type="text/JavaScript">

    var out;

    function main() {
      out = document.getElementById('out');
      print('History length: ' + history.length);
    }

    function print(txt) {
      out.innerHTML += txt + "<br>";
    }

  </script>

</head>
<body onload='main()'>

  <a href='length_2.html'>go to length_2.html</a>

  <div id='out'>
  </div>

</body>
</html>
Github repository Browser-Object-Model, path: /history/length_1.html
<!DOCTYPE html>
<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  <title>history.length</title>

  <script type="text/JavaScript">

    var out;

    function main() {
      out = document.getElementById('out');
      print('History length: ' + history.length);
    }

    function print(txt) {
      out.innerHTML += txt + "<br>";
    }

  </script>

</head>
<body onload='main()'>

  <a href='length_1.html'>go to length_1.html</a>

  <div id='out'>
  </div>

</body>
</html>
Github repository Browser-Object-Model, path: /history/length_2.html

images

links

navigator

navigator.userAgent returns the browser's HTTP User Agent string.

screen

Browser Object Model: The screen object

window

window.location

window.location.href The URL of the content that is displaed in the window
window.location.hostname The domain of href
window.location.pathname The path component of href. Determine HTML document name in JavaScript with window.location.pathname.split('/').pop());.
window.location.protocol The protocol that was used to transmit the content to the browser, for example http or https.
window.location.assign(newUrl) load newUrl as document into window.

window.toString

<!DOCTYPE html>
<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  <title>window.toString</title>
</head>

<script type="text/javascript">
  function main() {
     var out  = document.getElementById('out');

     out.innerHTML = window.toString(); // [object Window]
  }

</script>
<body onload='main()'>

  <div id='out'>
  </div>

</body>
</html>

See also

See also

web browser

Index