
2. While modifying the document, it is easy to attach a style sheet to it.
The
addHeader() function appends a small header at the beginning of
the document with a style sheet and a comment.
function addHeader(document,rate)
{
var comment = document.createComment(
“Rate used for this conversion: “ + rate),
stylesheet = document.createProcessingInstruction(
“xml-stylesheet”,
“href=\”prices.css\” type=\”text/css\””),
topLevel = document.documentElement;
document.insertBefore(comment,topLevel);
document.insertBefore(stylesheet,comment);
}
To attach a style sheet, you can simply create a processing instruction.
addHeader() uses insertBefore() to control where ...