html - Javascript : How can I enter a '@' in an url? -


i got code let me change value in page using form submit in javascript, problem url not accept value @ (@ = %40 in url)

here code:

index.html

<form method="get" action="page.html">   <input type="text" id="my_text" name="my_text" />   <input type="submit" /> </form> 

page.html

<input id="title"></input>  <script type="text/javascript">   function geturlvars() {     var vars = {};     var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,            function(m,key,value) {       vars[key] = value;     });     return vars;   }   document.getelementbyid("title").value = geturlvars()["my_text"]; </script> 

how can fix problem?

you want use encodeuri(), see this answer in depth explanation.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -