Valid, yes, but used presentationally. It's on the same order as tables for layout. Properly, it should be written using CSS display: block; or so.
Here's an abstraction of this behaviour:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Page Without Title</title>
<script type="text/javascript">
function Service(f, opts) {
this.tid = null;
this.f = f;
this.interval = opts.interval || 1000;
this.init = opts.init || Service.NONE_FUNCTION;
this.final = opts.final || Service.NONE_FUNCTION;
this.stopCond = opts.stopCond || Service.NONE_FUNCTION;
}
Service.prototype = {
start: function() {
if (!this.tid) {
this.init();
this.tick();
this.tid = setInterval(function() { this.tick(); }, this.interval);
}
},
tick: function() {
if (this.stopCond())
this.stop();
else
this.f();
},
stop: function() {
if (this.tid && !this.final) {
clearInterval(this.tid);
this.tid = null;
}
}
};
Service.NONE_FUNCTION = function() { return false; };
function alertku() {
var el = document.getElementById('alertku_span');
(el.firstChild || el.appendChild(document.createTextNode(""))).nodeValue += ', run';
}
var sAlertku = new Service(alertku);
</script>
</head>
<body>
<div>
<input type="button" value="RUN" onclick="sAlertku.start();">
<input type="button" value="STOP" onclick="sAlertku.stop();">
<span id="alertku_span">hum</span>
</div>
</body>
</html>
Bookmarks