How can I invoke Javascript without user input?
The usual way to invoke a script without a direct user action is to attach a function to the browser window’s onload event handler. This event occurs when an HTML document is fully loaded and will automatically call your function. There are two ways to declare an onload event handler: add an onload attribute to the body element of the HTML, or assign the function in your Javascript, as below.