Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript get querystring [duplicate]

Possible Duplicate:
obtaining querystring from current url in javascript?

I was to get everything after the question mark in the url. Ive seen a way to do it that does not require a function but cannot find it for the life of me.

url

fsdhfbsdfj/index.html?hello

get

hello
like image 592
user1898657 Avatar asked Jan 22 '13 16:01

user1898657


1 Answers

Use

var query = window.location.search;

If you want to get rid of the starting "?", use

var query = window.location.search.slice(1);

The properties of the location object are described here.

like image 137
Denys Séguret Avatar answered Sep 20 '22 19:09

Denys Séguret