I’m experimenting with write method & onload event. Here is my code:
<!DOCTYPE html>
<html>
<head>
</head>
<body onload="document.write('body loaded!')">
<h1>Hello World!</h1>
<img onload="document.write('img loadeld!')" src="smiley.gif" alt="Smiley face" width="42" height="42" />
</body>
</html>
What would be be the sequence of events in this case? Would the browser first create body element & call “body loaded” or the img element would be created first?
I would suggest you to create a
divthan useinnerHTMLproperty to write something in to it. A sample code would be:Javascript part: