Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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?

irt.org | Knowledge Base | JavaScript | Link | Q1743 [ previous next ]

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?

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.