javascript - Parsing email from query string -


i'm trying create piece of js parse email address url query string. once that's done, want send results anaytics use in whatever need use in.

so abc.com?wemail=abc@abc.com

<script type="text/javascript"> /*extracts email query string using ?email=name@abc.com*/  function geturlvalue(varsearch) {   var searchstring = window.location.search.substring(1);   var variablearray = searchstring.split('&');   (var = 0; < variablearray.length; i++) {     var keyvaluepair = variablearray[i].split('=');     if (keyvaluepair[0] == varsearch) {       return keyvaluepair[1];     }   } 

the anayltics receiving data, @ sign being replaced %40 , isn't coding way want.

i'm sure simple, changes need made ensure works properly?

the @ symbol used when url contains authentication info:

user:pass@myurl.com 

so modern browsers encode @ symbol in query string %40. use decodeuricomponent() decode value before sending segment.

https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/decodeuricomponent


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -