# variables in URL address in js
How can i retrieve variables from the URL address? am using this code but it is not working:
var x=window.location;
var y = x.indexOf('#', 0);
x=x.substring(y,x.length);
am receiving the following error:
Error: x.indexOf i开发者_开发知识库s not a function
What you want is not window.location but window.location.href
Still, I would use window.location.hash
You get the error because window.location
is an object, not a string. Try window.location.hash
to obtain the part after the #
.
精彩评论