From time to time I still use HTA (HTML Application) to create a quick (and dirty) user interface for minor automation tasks. This is a quick example on how a dynamic document can be created and used.
The start document looks like this:
After clicking "New Document" the document looks like this:
The code is written in JScript and looks like this:
<?xml version=1.0" encoding=utf-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>
<head>
<title>Dynamic Document</title>
<hta:application id="htaDynamicDocument" applicationname="DynamicDocument">
<script type="text/javascript" language="javascript">
function writeNewDoc() {
writeHeader();
document.writeln("<p>This is a new document.</p>");
writeFooter();
}
function writeHeader() {
document.clear();
document.writeln("<h1>Dynamic Document</h1>");
}
function writeFooter() {
document.writeln("<p>© 2008, Niels Grove-Rasmussen</p>");
}
function startDocument() {
writeHeader();
var MarkUp = "<p>";
MarkUp += '<input type="button" value="New Document" ';
MarkUp += 'onclick="writeNewDoc();" ';
MarkUp += 'title = "Open new document." />';
MarkUp += "</p>";
document.writeln(MarkUp);
writeFooter();
}
</script>
</head>
<body>
<script type="text/jscript" language="jscript">
startDocument();
</script>
</body>
</html>
<?xml version=1.0" encoding=utf-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>
<head>
<title>Dynamic Document</title>
<hta:application id="htaDynamicDocument" applicationname="DynamicDocument">
<script type="text/javascript" language="javascript">
function writeNewDoc() {
writeHeader();
document.writeln("<p>This is a new document.</p>");
writeFooter();
}
function writeHeader() {
document.clear();
document.writeln("<h1>Dynamic Document</h1>");
}
function writeFooter() {
document.writeln("<p>© 2008, Niels Grove-Rasmussen</p>");
}
function startDocument() {
writeHeader();
var MarkUp = "<p>";
MarkUp += '<input type="button" value="New Document" ';
MarkUp += 'onclick="writeNewDoc();" ';
MarkUp += 'title = "Open new document." />';
MarkUp += "</p>";
document.writeln(MarkUp);
writeFooter();
}
</script>
</head>
<body>
<script type="text/jscript" language="jscript">
startDocument();
</script>
</body>
</html>
HTA is described by Microsoft at HTA Developers Center.
No comments:
Post a Comment