<!- the namespace declaration for the download page object -->
<html xmlns:javaScriptDownload>
<head>
<title>Behaviors</title>
<script type="text/javascript">
// set the hidden field's value to the contents of the text file
// we store the text here after the download.
function setDlProc(obj) {
document.all.download.value=obj;
}
// parse over the contents, since we want to have each fruit on it's own line
// we relace all newline characters(\n) with an HTML newline(<BR>)
function writeToDoc(){
var re = new RegExp ("\n", "g");
str = document.getElementById("download").value.replace(re, "<BR>");
str = str.replace(re, "<br>");
document.getElementById('textFileCOntentsOnPage').innerHTML = str;
}
function runTest(){
// invoke the behavior on the namespace specified download page object
document.getElementById('fileDlBehavior').startDownload('test.txt',setDlProc);
// set the contents of the display area to show that were getting the file
document.getElementById('textFileCOntentsOnPage').innerHTML = "Downloading the text file...";
// write the contents of the text file to the page display area
setTimeout("writeToDoc()", 1500);
}
</script>
</head>
<body>
<!- the the button you click to invoke the test -->
<input type='button' value='Run Test' onclick="runTest()"><hr>
<!- the namespace specified download page object -->
<javaScriptDownload:download id="fileDlBehavior" style="behavior:url(#default#download);" />
<!- the hidden field that stores the text file contents after download -->
<input type='hidden' id="download" name='download' style='visibility:hidden'>
<!- The display area for the test results -->
<span id='textFileCOntentsOnPage' name='textFileCOntentsOnPage'></span>
</body>
</html>