onload = myFunction(); - Javascript DOM Event

Javascript examples for DOM Event:Element Event Attribute

Description

The onload event occurs when an object has been loaded.

Summary

Bubbles No
Cancelable No
Supported HTML tags: <body>, <frame>, <iframe>, <img>, <input type="image">, <link>, <script>, <style>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
<iframe id="myFrame" src="http://java2s.com"></iframe>

<p id="demo"></p>

<script>
document.getElementById("myFrame").onload = function() {myFunction()};

function myFunction() {//w  w  w  .  j  a v  a 2 s.c  om
    document.getElementById("demo").innerHTML = "Iframe is loaded.";
}
</script>

</body>
</html>

Related Tutorials