Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2005
    Location
    Milton Keynes, UK
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with replacing  

    Is it possible to create a javascript that replaces the   within a HTML document with a regular space.

    Basically my problem is this. I have a piece of Java code which spits out a string of options based on how a user navigates to a page, unfortunately for all the white space generated by this code it puts in   instead of a space. As i don't own the code that creates the string, I cannot edit it from that end, so I thought I could write a quick JavaScript that would find instances of   and replace them with a regular old space.

    Any help would be greatly appreciated.

  • #2
    New Coder
    Join Date
    Feb 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    are you a ware that if you replace,say, 6   with 6 regular spaces the browser will treat it as only 1 space?

    If you don't care I can show you how to remove the  's
    Asp.Net 1.1 - 20 hrs
    CSS 2.0 - 3 hrs
    XHTML 1.1 - 5hrs
    JavaScript - 5hrs
    Cross-Browser Compatibility - Priceless

  • #3
    New Coder
    Join Date
    Jul 2005
    Location
    Milton Keynes, UK
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That would be great, the string only spits out one   between options, , kinda like:

    Option 1 Option2 Option3 and so on...

    Luckily it's the only bit on the page like this, so that would be an ideal solution if you would show me. Thank you
    Last edited by takuhii; 10-19-2005 at 03:25 PM.

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by takuhii
    Is it possible to create a javascript that replaces the   within a HTML document with a regular space.

    Basically my problem is this. I have a piece of Java code which spits out a string of options based on how a user navigates to a page, unfortunately for all the white space generated by this code it puts in   instead of a space. As i don't own the code that creates the string, I cannot edit it from that end, so I thought I could write a quick JavaScript that would find instances of   and replace them with a regular old space.

    Any help would be greatly appreciated.
    Code:
    document.body.innerHTML=document.body.innerHTML.replace(/\&nbsp\;/g,' ');


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •