<html>
  <head>
    <script language="JavaScript">
      function initialize(message) {
        // get our template that we will write into the iframe
        var templateDiv = document.getElementById("template");
        var currentElement = templateDiv.firstChild;
        // loop until we get a COMMENT_NODE
        while (currentElement && currentElement.nodeType != 8) {
          currentElement = currentElement.nextSibling;
        }
        var template = currentElement.nodeValue;

        // replace the templated value in the constants with our new value
        var newContent = template.replace(/\%message\%/g, message);

        // get our iframe
        var testFrame = document.getElementById("testFrame");

        // now write out the new contents
        var doc = testFrame.contentDocument;
        if (doc == undefined || doc == null)
		doc = testFrame.contentWindow.document;
        doc.open();
        doc.write(newContent);
        doc.close();
      }
    </script>
  </head>

  <body onload="initialize('Hello Template World!')">
    <div id="template">
      <!--
        <html>
          <head>
            <script language="JavaScript">
              function sayHello() { alert("%message%"); }
            </script>
          </head>
          <body onload="sayHello()">
            <p>%message%</p>
          </body>
         </html>
       -->
    </div>

    <iframe id="testFrame"></iframe>
  </body>
</html>