Answers for "send data from one page to another html page in Javascript"

0

send data from one page to another html page in Javascript

//use this in page one
//where you will send data from
function testJS() {
    var b = document.getElementById('name').value,
        url = 'http://path_to_your_html_files/next.html?name=' + encodeURIComponent(b);

    document.location.href = url;
}
//use the following code where you want to receive data
window.onload = function () {
    var url = document.location.href,
        params = url.split('?')[1].split('&'),
        data = {}, tmp;
    for (var i = 0, l = params.length; i < l; i++) {
         tmp = params[i].split('=');
         data[tmp[0]] = tmp[1];
    }
    document.getElementById('here').innerHTML = data.name;
}
Posted by: Guest on September-16-2021

Code answers related to "send data from one page to another html page in Javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language