<html>
<head>
<title>Abakada DHTML Demo: Insert HTML Sample</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="JavaScript">
<!--
function insertScript ( ) {
if ( scriptDiv.innerHTML == "" ) {
var sHTML = "<input type=button onclick='sayHello ( )' value='Click Me'>";
var sScript = "<script defer>";
sScript += "function sayHello ( ) {";
sScript += "alert ( 'Hello. This message is from the inserted script.' ) }";
sScript += "</script>";
scriptDiv.insertAdjacentHTML ( "afterBegin", sHTML + sScript );
}
else alert ( 'The script is already available.' );
}
//-->
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>Abakada DHTML Demo: Insert HTML Sample</h2></div>
<hr size=1 width=92%>
<center>
<p id="msg">This example shows use of the <b>innerHTML</b> property to check for the existence of content on a <b>DIV</b>. A function inserts a script into the <b>DIV</b> if it isn't already there, using the <b>insertAdjacentHTML</b> method. </p>
<h5><a href="javascript: insertScript ( )">Click</a> to insert the script. </h5>
<div class="back" id="scriptDiv"></div>
</center>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>