send data from one page to another html page in javascript

Solutions on MaxInterview for send data from one page to another html page in javascript by the best coders in the world

showing results for - "send data from one page to another html page in javascript"
Dounia
09 Jul 2017
1//use this in page one
2//where you will send data from
3function testJS() {
4    var b = document.getElementById('name').value,
5        url = 'http://path_to_your_html_files/next.html?name=' + encodeURIComponent(b);
6
7    document.location.href = url;
8}
9//use the following code where you want to receive data
10window.onload = function () {
11    var url = document.location.href,
12        params = url.split('?')[1].split('&'),
13        data = {}, tmp;
14    for (var i = 0, l = params.length; i < l; i++) {
15         tmp = params[i].split('=');
16         data[tmp[0]] = tmp[1];
17    }
18    document.getElementById('here').innerHTML = data.name;
19}