Loop through URL GET variables with javascript -



Loop through URL GET variables with javascript -

i know can obtain url variable calling geturlvars()["id"], there way (an unknown number of) variables in url? few reasons allowed on client side.

try this:

function geturlvars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexof('?') + 1).split('&'); for(var = 0; < hashes.length; i++) { hash = hashes[i].split('='); vars[hash[0]] = hash[1]; } homecoming vars; } var url_vars = geturlvars(); for(var in url_vars) { alert(i + " == " + url_vars[i]); }

javascript url get

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -