HTML and CSS Reference
In-Depth Information
There also are some document-related event handlers that occur when
various document elements get handled by the browser. For instance,
the onLoad event may happen when a frameset is complete or when the
body of an HTML or XHTML document gets loaded and displayed by the
browser. Similarly, onUnload occurs when a document is removed from a
frame or window.
12.3.4. javascript URLs
You can replace any conventional URL reference in a document with
one or more JavaScript statements. The browser then executes the
JavaScript code, instead of downloading another document, whenever
the browser references the URL. The result of the last statement is taken
to be the "document" referenced by the URL and is displayed by the
browser accordingly. The result of the last statement is not the URL of a
document; it is the actual content to be displayed by the browser.
To create a javascript URL, use javascript as the URL's protocol:
<a href="javascript:generate_document()">
In this example, the JavaScript function generate_document() gets ex-
ecuted whenever the user selects the hyperlink. The value returned by
the function, presumably a valid HTML or XHTML document, is rendered
and displayed by the browser.
It may be that the executed statement returns no value. In this case,
the current document is left unchanged. For example, this javascript
<a href="javascript:alert('Error!')">
Search WWH ::

Custom Search