How to get the query string by javascript?

前端 未结 10 1600
深忆病人
深忆病人 2020-11-27 03:36

How to extract the query string from the URL in javascript?

Thank you!

10条回答
  •  伪装坚强ぢ
    2020-11-27 04:03

    I have use this method

    function getString()
    {
    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;
    }
    var buisnessArea = getString();
    

提交回复
热议问题