Javascript DOM onload Event via HTML Tag onload attribute

Introduction

This example demonstrates how to assign an "onload" event to an iframe element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<iframe onload="myFunction()" src="https://www.java2s.com"></iframe>
<p id="demo"></p>
<script>
function myFunction() {//  ww w.ja  va2  s .  c o  m
  document.getElementById("demo").innerHTML = "Iframe is loaded.";
}
</script>

</body>
</html>
Bubbles:
Cancelable:
Event type:
Supported HTML tags:







No
No
UiEvent if generated from a user interface, Event otherwise.
<body>,
<frame>,
<iframe>,
<img>,
<input type="image">,
<link>,
<script>,
<style>



PreviousNext

Related