Q1743 When placing the value of a JavaScript variable into a URL request, how do I correctly format the variable value, so that spaces etc are converted into the standard html request syntax?
You are here: irt.org | FAQ | JavaScript | Link | Q1743 [ previous next ]
Use the escape() method, for example:
<script language="JavaScript"><!--
var data = 'Hello world';
var url = 'http://somewhere.com/index.htm?name=' + escape(data);
location.href = url;
//--></script>
Feedback on 'Q1743 When placing the value of a JavaScript variable into a URL request, how do I correctly format the variable value, so that spaces etc are converted into the standard html request syntax?'
©2018 Martin Webb