I have a location property in my URL that I want to be used as the header on my website.
My current URL looks like this: http://localhost:37675/Directory/Home?location=Carol%20Stream
This is my header:
<h2 id="cookie1" class="col-xs-offset-2 col-xs-10 col-sm-offset-4 col-sm-4 col-md-offset-5 col-md-3"></h2>
When I use this JavaScript code:
(function () {
var myParam = location.search.split('location=')[1];
myParam.replace(/%20/g, ' ');
document.getElementById("cookie1").innerHTML = myParam;
})();
My header looks like this:
When I use this java script code:
(function () {
var myParam = location.search.split('location=')[1];
decodeURIComponent(myParam);
document.getElementById("cookie1").innerHTML = myParam;
})();
My header still looks like this:
Why do neither .replace or DecodeURIComponent work in replacing the %20 in my URL with a space?
I have looked at these stack exchange posts and none have worked for me:
Javascript replace all "%20" with a space