jQuery setting variables from url string -


i have url string http://www.example.com/?chicken?toast

and want able store values after each of ? characters.

i have working getting last ?value - cant seem store first...

code works last ?value is:

window.lastvalue = window.location.href.substring(window.location.href.lastindexof('?') + 1); 

how can store first also?

so firstvalue = chicken , lastvalue = toast

update - how can store totalval flattening array? so, if array ["chicken", "toast"] need flattened string "." before each item in array - if array ["chicken", "toast"] become ".chicken.toast" - if array ["chicken"] become ".chicken" // thanks

cheers,

this give array of values want:

var r = window.location.href.split("?"); r.shift(); console.log(r); 

if there 2 values, can use extract them:

var val1 = r.shift(); var val2 = r.shift(); 

here's version gives .chicken result:

var r = window.location.href.split("?"); r[0]=''; var totalval = r.join('.'); 

Comments

Popular posts from this blog

testing - Detect whether test has failed within fixture -

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

android - Create single AAR file from multiple modules using Gradle -