Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8533003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:51:09+00:00 2026-06-11T09:51:09+00:00

The following function only replaces the first <br /> it finds, not the following

  • 0

The following function only replaces the first “<br />” it finds, not the following ones. Does anyone know how to fix that problem?
I want the function to replace all the strings in the whole document.

<script language="javascript" type="text/javascript">
    window.onload = function umtauschen()
    {
    document.body.innerHTML = document.body.innerHTML.replace('&lt;br /&gt;', '<br />');
    document.body.innerHTML = document.body.innerHTML.replace('&lt;b&gt;', '<b>');
    document.body.innerHTML = document.body.innerHTML.replace('&lt;/b&gt;', '</b>');
    }
</script>

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:51:11+00:00Added an answer on June 11, 2026 at 9:51 am

    Use regular expressions, and the g (global) flag:

    document.body.innerHTML = document.body.innerHTML
        .replace(/&lt;br \/&gt;/g, '<br />')
        .replace(/&lt;b&gt/g, '<b>')
        .replace(/&lt;\/b&gt;/g, '</b>');
    

    Another option is to use the .split(find).join(replace) idiom:

    document.body.innerHTML = document.body.innerHTML
        .split('&lt;br /&gt;').join('<br />')
        .split('&lt;b&gt;').join('<b>')
        .split('&lt;/b&gt;').join('</b>');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function that I only want to run inside <div id=imgWrapper>
I don't know enough to change the following so that it only puts <strong>
I have the problem that rails 2.X do not replaces a backslash (\) with
the following javascript function only seems to work when i have the final confirm()
Will GHC perform tail-call optimization on the following function by default? The only weird
i have a variable like the following and i want a function to only
How can you do something like the following? $('.myDivs').ontouchstart(function(){ alert('touch'); }) the only way
The following function rewrites urls from news and product titles that contain all sorts
The following function that reports the current line-number (and time) which I would like
Im trying to write a function that will convert all charactewrs after the first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.