How to write content one HTML page to another HTML page using JavaScript

Rajni.Shekhar
Posted by Rajni.Shekhar under JavaScript category on | Points: 40 | Views : 2796
Lets say you have two pages a.html and b.html and you want to write in a.html page that will be shown in b.html page.

a.html

<html>
<form type=get action="b.html">
<table>
<tr>
<td>Type Text Here:</td>
<td><input type=text name=yourtext size=10></td>
</tr>
<tr>
<td>
<input type="Submit" name=submit>
</td>
</tr>
</table>
</form>
</html>

b.html

<html>
<script LANGUAGE="JavaScript">
function getParameters(){
var index = document.URL.indexOf('?');
var params = new Array();
if (index != -1) {
var pairs = document.URL.substring(index+1, document.URL.length).split('&');
for (var i=0; i<pairs.length; i++){
paramName = pairs[i].split('=');
params[paramName[0]] = paramName[1];
}
}
return params;
}
params = getParameters();
yourtext = unescape(params["yourtext"]);
document.write("Your Text = " + yourtext + "<br>");
</script>
</html>

Comments or Responses

Login to post response