window.onload = function () {
This line initiates an anonymous function and appends it to the window.onload
event, i.e. the code within the function will be executed at when the page and all its resources are loaded in the DOM.
'use strict';
This line says that the proceeding code is to be executed in strict mode, which means that a handful of common pitfalls and dubious codes will be treated as errors. See more on strict mode here.
var antwoord = function(tekst) {
This line initiates a function named antwoord
(not really: see comments) that accepts one parameter (tekst
).
var berichtvenster = document.getElementById('berichtvenster');
This line looks for an element of the ID "berichtvenster", and assigns a reference to that element, if any is found, to the newly created variable of the same name.
berichtvenster.innerHTML += "<p>" + tekst + "</p>\n";
This line assumes that such an element was indeed found, and proceeds to update its innerHTML
property, i.e. to change the HTML content of the element. It changes the content to be a paragraph containing only the text that was passed to the antwoord
function.
` to the existing contents of the element whose id is `berichtvenster`.
– Michael Berkowski Apr 11 '13 at 13:16