Create custom page and replace current document with it : Toggle : GUI Components JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » GUI Components » Toggle »

 

Create custom page and replace current document with it



<!-- ***********************************************************
Example 5-2
"Dynamic HTML:The Definitive Reference"
2nd Edition
by Danny Goodman
Published by O'Reilly & Associates  ISBN 0-596-00316-1
http://www.oreilly.com
Copyright 2002 Danny Goodman.  All Rights Reserved.
************************************************************ -->
<html>
<head>
<title>Welcome Page</title>
<script language="JavaScript" type="text/javascript">
// create custom page and replace current document with it
function rewritePage(form) {
    // accumulate HTML content for new page
    var newPage = "<html>n<head>n<title>Page for ";
    newPage += form.entry.value;
    newPage += "</title>n</head>n<body bgcolor='cornflowerblue'>n";
    newPage += "<h1>Hello, " form.entry.value + "!</h1>n";
    newPage += "</body>n</html>";
    // write it in one blast
    document.write(newPage);
    // close writing stream
    document.close();
}
</script>
<body>
<h1>Welcome!</h1>
<hr>
<form onsubmit="return false;">
<p>Enter your name here: <input type="text" name="entry" id="entry"></P>
<input type="button" value="New Custom Page" onclick="rewritePage(this.form);">
</form>
</body>
</html>
 

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo GUI Components
» Toggle