开发者

How to detect of a requested URL contains query string?

I want to detect if a requested URL contains qu开发者_运维知识库ery string or not. How can I do so?


You can directly use getQueryString() method

OR

You can check if your url has a query string or not by splitting it on "?" or finding index of the "?" character.

On splitting, your result array must have atleast length greater than 1 and if you take the index route, then the index must be greater than 0 since first character cant be a "?" assuming you will have correct url entered to check for query string.


Something like requestedUrl.indexOf("?") > 0 should do. Because query string parameters are passed by appending ? to the url and then name/value pairs follow.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜