Rewrite Page

[Total: 0    Average: 0/5]

This script shows how to have a page completely re-written by javascript.

Head Code:

<script>
/*
This script is designed to show how NS4 can be used to dynamically update content on the page.
*/
function addRow(_v)
{
  var _html="<html><head>";
      _html+="<"+"script>";
	  _html+="function addRow(_v){";
	  _html+="var _html='you figure this one out as this gets complicated fast!';";
	  _html+="document.open();document.write(_html);document.close();";
	  _html+="return false;}";
	  _html+="<"+"/script>";
      _html+="</head><body>";
	  _html+="<table width=400 height=300 border=1><tr><td height=300 width=400>";
	  _html+=_v;
	  _html+="</td></tr></table>";
	  _html+="<hr width=55% color=steelblue height=1 align=center>";
	  _html+="<form name=exf1 onsubmit='return addRow(this.t1.value)'>";
	  _html+="<input type=text name=t1 value='next default'>&nbsp;&nbsp;&nbsp;";
	  _html+="<input type=submit value='Add Another Row'>";
	  _html+="</form>";
	  _html+="</body></html>";
  document.open();
  document.write(_html);
  document.close();
  return false; /* kill the submit */
}
</script>

Body Code:

<table width=400 height=300 border=1>
<tr><td height=300 width=400>&lt;&lt;EMPTY&gt;&gt;</td></tr>
</table>
<hr width=55% color=steelblue height=1 align=center>
<form name=exf1 onsubmit="return addRow(this.t1.value)">
<input type=text name=t1 value="default text">&nbsp;&nbsp;&nbsp;
<input type=submit value="Add Row">
</form>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *