开发者

# 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 #.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜