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 3 of 3

Thread: word replace

  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    word replace

    how do you tell a page to replace a certin word with another specified word everywhere its listed on the page. I don't mean like find and replace I mean like at run time.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quick & dirty way
    Code:
    function replaceWord( word, replacment )
    {
        var pattern = new RegExp( word, "i" );
        document.body.innerHTML = document.body.innerHTML.replace( pattern, replacement );
    }
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Best off doing this server-side before the page is returned to the client in many cases - but of course, that depends on your purpose. Which is?
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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