stylesheet processing instruction in XML file, e.g.
<?xml-stylesheet type="text/xsl" href="rss-headlines.xsl"?>
rss-headlines.xsl,
rss-fragment-headlines.xml displays
just headlines (titles of items)<script> element specifies script to be
executedOnLoad, OnUnload
OnClick, OnDblClick
onMouseDown, onMouseUp,
onMouseOver, onMouseMove,
onMouseOut
onKeyPress, onKeyDown,
onKeyUp
<script type="text/javascript" language="JavaScript">;
document.write("Hello World!");
</script>
language attribute is deprecated (only valid in
(X)HTML transitional)<script type="text/javascript" language="JavaScript">;
<!--
document.write("<em>Document title:</em> ",
document.title, "<br />");
document.write("<em>Last modified:</em> ",
document.lastModified);
// -->
</script>
title is a property defined on
document, which retrieves the titlelastModified is a property defined on
document, which retrieves the date and time when the
document was last modified//") preceding it
<script type="text/javascript" language="JavaScript">;
document.write("<em>userAgent:</em> ",
navigator.userAgent, "<br />");
document.write("<em>Document links:</em><ul>");
for(i = 0; i < document.links.length; i++) {
document.write("<li>",
document.links[i], "</li>");
}
document.write("</ul>");
</script>
navigator is a special object referring
to the browser in useuserAgent is a property of
navigator, which returns information sent by the
browser in the user-agent header in HTTP requests (see
later)links is a property defined on
document, which returns an array of
anchor elements in the documentlength is a property defined on arrays,
which returns the number of elements in the array[i]
for loop cycles through each element of the
array, starting with i = 0 and incrementing i by 1,
using i++, each time around the loop, until i becomes
equal to the number of items in the array<a href="mylink.html">hyperlink</a>
<a href="mylink.html" onMouseOver="window.status='Click here'; return true;" onMouseOut="window.status=''; ">hyperlink</a>
onMouseOver and onMouseOut are
events
window is an object representing the web
browser windowstatus is a property of window,
which specifies the contents of the status linereturn true is needed to ensure the browser does
not overwrite the status line<form> <input type="button" value="Click to open window" onClick="window.open('birkbeck.html', 'window1', 'width=235, height=75')" /> </form>
birkbeck.html containing:
<html> <head><title>Birkbeck</title></head> <body><img src="birkbeck.gif" /></body> </html>
form element indicates an HTML forminput element creates a button with the
given value displayed on itonClick is an event
open is a method of window,
which opens a new window called window1 and
displaying the URL birkbeck.html
<script type="text/javascript" language = "JavaScript"> var num; // Display a prompt with a zero in it num = window.prompt("Enter an integer", "0"); document.writeln("<table border = '1' align='center'>"); var count = 0; while (count < num) { // Display each line of the table, // each line is an integer and its square document.writeln("<tr><td>", count, "</td> <td>", count*count, "</td></tr>"); count++; } document.writeln("</table>"); </script>
var declares a variable for storing values
for later usecount is set to zeroprompt is a method of window,
which opens a dialog box with the given message and default value
for the input; it returns the value entered by the userwriteln is a method of document,
which writes text followed by a new line into the documentwhile is a loop which continues to execute
its loop body (between { and }) until its
condition (count < num) is falsecount++ adds one to the value of the variable
count, i.e., it is the same as count = count+1
<form> <table> <tr> <td>Enter an expression:</td> <td><input type="text" name="expr" size=15 /></td> </tr> <tr> <td></td> <td><input type="button" value="Determine value" onClick="myEvaluate(this.form)" /></td> </tr> <tr> <td>Value:</td> <td><input type="text" name="result" size=15 /></td> </tr> </table> </form>
myEvaluate is
defined by the script on the next slideonClick attribute is a
script which calls the function
myEvaluate
this refers to the
input element in which it occursthis.form returns a reference to the form
in which the input element occursmyEvaluate is
defined by the script:
<script type="text/javascript" language="JavaScript">; function myEvaluate(f) { if (window.confirm("Are you sure?")) f.result.value = eval(f.expr.value) else window.alert("Please try later") } </script>
f is a reference to the form
element in which the function myEvaluate was calledconfirm is a method of window,
which opens a dialog box with the given message; it returns the value
true if the user clicks the OK button, false if the user clicks Canceleval is a function which returns the result
of evaluating its argumentresult and expr are named
input elements
of the form referred to by f
value is the contents of the named input
elements
of the form referred to by f
alert is a method of window,
which displays the given message in a dialog box which contains an
OK button
documentis a special object referring to the document displayed in the browser windowwriteis a method defined on an HTMLdocument, which writes text into it