📎

JavaScript and the Browser

Execution Model

For each window / tab / frame:

  1. Load content
  1. Render pages

    Fetch additional ressources.

    Process HTML, style sheets, scripts to display the page

  1. React to events

    User actions :OnClick,OnMouseover, …

    Rendering :OnLoad,OnUnload, …

    Timing: setTimeout,clearTimeout, …

Embedding Javascript

Inlined in the page

<script>alert("Hello World!");</script>

Stored in external files

<script type="text/javascript" src="foo.js"></script>

Specified as event handlers

<a href="http://www.bar.com" onmouseover="alert('hi');">

Pseudo-URLs in links

<a href="javascript:alert('You clicked');">Click me</a>

DOM and BOM

APIs accessible through Javascript.

Browser Object Model BOM → interact with browser

Window,Frames,History,Location,Navigator (browser type & version), ...

Document Object Model DOM → interact with HTML page

Properties: document.forms,document.links , …

Methods: document.createElement,document.getElementsByTagName , …