How can I pass a value from one HTML page to another using JavaScript?

后端 未结 4 1054
时光取名叫无心
时光取名叫无心 2020-12-10 01:53

This is my first HTML page:

   

    
    
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 02:27

    Found a solution for you to parse GET variables:

    // Read a page's GET URL variables and return them as an associative array.
    function getUrlVars()
    {
        var vars = [], hash;
        var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
        for(var i = 0; i < hashes.length; i++)
        {
            hash = hashes[i].split('=');
            vars.push(hash[0]);
            vars[hash[0]] = hash[1];
        }
        return vars;
    }
    

    Get URL parameters & values with jQuery

提交回复
热议问题