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 7889347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:04:29+00:00 2026-06-03T06:04:29+00:00

I have a situation where elements are changed on the fly through a specific

  • 0

I have a situation where elements are changed on the fly through a specific component.
This component changes the innerHTML of these elements but doesn’t actually rerender the element, but rather only its contents.
This leads to situations where the final DOM is different than it would be had it been on the page in the first place – this is a problem for me.

An example of such a mix up is this:
If we take the following markup:

<h1 id="foo">Hi there stranger!</h1>

And I add the following JS code:

document.getElementById('foo').innerHTML = "Hi <h2>there</h2> stranger!";

We will result with the following markup:

<h1 id="foo">Hi <h2>there</h2> stranger!</h1>

It will be rendered same as seen above (with the H2 inside the H1), but if this markup were on the page in the first place it would get rendered as:

<h1>Hi</h1> <h2>there</h2> <h1>stranger!</h1>

Which obviously results in a different document.

So, my question is this:
How can I force the browser to rerender this markup?
I’d like to be able to refer to the above H1 and tell it to rerender in the same way it would have rendered in the first place.
How can I do this in all the major engines (Gecko, Webkit, IE)?

  • 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-03T06:04:31+00:00Added an answer on June 3, 2026 at 6:04 am

    I’d call this “attempt to fix invalid markup”, rather than “rerender”. Anyways, you should assign html to a node that is higher in the hierarchy than the node in question. As a last resort, reloading the whole <body> should work:

     document.body.innerHTML = document.body.innerHTML
    

    Another option would be to use outerHTML, that is:

    document.getElementById('foo').outerHTML = "<h1>Hi <h2>there</h2> stranger!</h1>";
    

    At least in FF, this appears to work as intended.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where particular elements (xs:simpleType, xs:complexType) are placed in the output
I have the following situation: A stackpanel contains a number of elements, including some
i have situation like this: class IData { virtual void get() = 0; virtual
I have situation like this: user submits form with action='/pay' in '/pay' I have
I have seen that the situation is very problematic after reading these: IE6/IE7 css
I have elements of a list in couchdb documents. Let's say these are 3
I'm dealing with this situation : I have a color animation script which targets
I have run into a strange situation where I need to float two elements.
I have situation, where running a query that filters by an indexed column in
I have situation in which I read a record from a database. And if

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.