<html> <body> <script language="JavaScript"> function function1() { var newDoc = document.createDocumentFragment(); newDoc.innerHTML = "<p>Body Content</p>"; alert(newDoc.innerHTML); } </script> <input id="myT" type="button" value="Click me" onclick="function1();"> </body> </html>