115
rated 0 times
[
116]
[
1]
/ answers: 1 / hits: 28848
/ 11 Years ago, wed, february 27, 2013, 12:00:00
I want to print out a message in the page's <div>
element upon page load. I have the following HTML and JavaScript code:
<body onload=printMsg()>
<div id=write></div>
</body>
function printMsg() {
var node = document.getElementById(write);
node.innerHTML = <p> + Hello World! + </p>;
}
Here I used onload
event in <body>
element to call printMsg()
upon page load.
But if I don't use onload
event, is there any alternative way to write to <div id=write></div>
directly within the JavaScript function printMsg()
?
More From » html