Javascript Examples

From I Will Fear No Evil
Revision as of 11:28, 5 July 2023 by Chubbard (talk | contribs) (Chubbard moved page Javascript to Javascript Examples)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

I HATE JavaScript

Did I mention I hate it? Well that does not matter. It is used all over, and I am going to have to learn to deal with it.. Here are some examples and notes that can be integrated and not cause troubles in most applications

JS clock on page

Found example at display-clock-inside-the-html-page-or-div

<script>
function startTime() {
    var today = new Date();
    var h = today.getHours();
    var m = today.getMinutes();
    var s = today.getSeconds();
    m = checkTime(m);
    s = checkTime(s);
    document.getElementById('txt').innerHTML =
    h + ":" + m + ":" + s;
    var t = setTimeout(startTime, 500);
}
function checkTime(i) {
    if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
    return i;
}
</script>
<body onload="startTime()">
<div id="txt"></div>