Jump to content

Execute Javascript After Iframe Has Loaded..?


cyfer65

Recommended Posts

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"   "http://www.w3.org/TR/html4/strict.dtd"><html>	<head>		<meta http-equiv="content-type" content="text/html;charset=UTF-8">		<title></title>		<script type="text/javascript">			function init () {				document.getElementById("myframe").onload = function () {					alert ("somewhere.html is completely loaded");				}			}			window.onload = init;		</script>	</head>	<body>		<div>Something</div>		<iframe src="somewhere.html" id="myframe"></iframe>	</body></html>

It is important to set the onload handler after the main window has loaded. If we tried to do it while the page was loading, the script would not find the iframe, because that part of the document wouldn't have been read yet.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...