Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Replace %20 ?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35461
    schart
    Participant

    I’v got some window.location.search.substring(1) trouble here. I am saving the window.location.searc(…) in a variable and inserting the variable as a value in a textbox. If the content transferred in the URL (window.location.search) has spaces, they get replaced with %20. Me no likey. Any way to replace all %20 in the textbox with ” “(space) . And yes, it has to be in a textbox.






    The code work’s, and this is not directly copied, it’s by memory. So please do not comment if I wrote the code wrong or something, because it works. Once again, just want to fix “%20” problem.

    Just to clarify, this is for example if I load the page with the code above like this:
    http://www.somedomain.com/somepage.html?This is location search thingy
    It will come out as
    This%20is%20location%20search%20thingy

    #91836
    Mottie
    Member

    Try this:

    var savedInfo = window.location.search.substring(1);
    document.myform.myinput.value = 'Some text ' + decodeURI(savedInfo) + '';
    #91837
    lcvcray
    Member

    Thanks, I’ve been wondering about that.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.