Skip to content

Instantly share code, notes, and snippets.

@kiebekierror
Created December 10, 2018 10:11
Show Gist options
  • Save kiebekierror/fde76cfb3c7fca8daf4c6a2e9e1a49e0 to your computer and use it in GitHub Desktop.
Save kiebekierror/fde76cfb3c7fca8daf4c6a2e9e1a49e0 to your computer and use it in GitHub Desktop.
前端 JavaScript location 变量研究
var IndexRedirect = {
getUrlVars : function ()
{
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
function (m,key,value)
{
vars[key] = value;
});
return vars;
},
// 获取当前目录
getDepthPath: function ()
{
console.log(location);
},
getSearch: function ()
{
return location.search;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment