Java Reference
In-Depth Information
As you can see, this basic XML fi le is populated with a different message for each day of the week.
Next is the HTML page, with the createDocument() function added in the script block.
<html>
<head>
<title>Message of the Day</title>
<script type=”text/javascript”>
function createDocument()
{
var xmlDoc;
if (window.ActiveXObject)
{
var versions =
[
“Msxml2.DOMDocument.6.0”,
“Msxml2.DOMDocument.3.0”
];
for (var i = 0; i < versions.length; i++)
{
try
{
xmlDoc = new ActiveXObject(versions[i]);
return xmlDoc;
}
catch (error)
{
//do nothing here
}
}
}
else if (document.implementation
&& document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument(“”,””,null);
return xmlDoc;
}
return null;
}
//More code to come
</script>
</head>
Before you dig into the body of the page, there's one more function to add to the head of the page. This
function is called getDailyMessage(), which retrieves and returns the message of the day. Add it
below the createDocument() function defi nition.
function getDailyMessage()
{
Search WWH ::




Custom Search