[Dev Tip] Create URI with space on parameter

use built-in method: encodeURIComponent()

<pre class="default prettyprint prettyprinted"><code><span class="kwd">var</span><span class="pln"> myOtherUrl </span><span class="pun">=</span><span class="str">"http://example.com/index.html?url="</span><span class="pun">+</span><span class="pln"> encodeURIComponent</span><span class="pun">(</span><span class="pln">myUrl</span><span class="pun">);</span></code></pre>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s