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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:36:38+00:00 2026-06-02T10:36:38+00:00

My code is: <body> <p id=tit></p> <script type=text/javascript> try { document.getElementById(‘tit’).innerHTML = <div>test</div>; }

  • 0

My code is:

<body>
    <p id="tit"></p>
    <script type="text/javascript">
        try {
            document.getElementById('tit').innerHTML = "<div>test</div>";
        }
        catch(e) {
            alert(e)
        }
    </script>
</body>

alert [object Error] in IE6/7/8, why?

  • 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-02T10:36:40+00:00Added an answer on June 2, 2026 at 10:36 am

    This (was) by design.

    An element <p> should contain only inline elements, from HTML specs:

    <!ELEMENT P - O (%inline;)* -- paragraph -->
    

    It may be not so clear but it means that <p> cannot contain a grouping element. Now in the <div> specification we can read:

    The DIV and SPAN elements, in conjunction with the id and class
    attributes, offer a generic mechanism for adding structure to
    documents. These elements define content to be inline (SPAN) or
    block-level (DIV) but impose no other presentational idioms on the
    content.

    The <p> element is not the only one that can contain only inline elements, headers (<h1>, <h2>,…) for example share the same behavior.

    Many browsers allowed malformed HTML to be inserted via innerHTML property so this strange behavior seemed to affect IE only. Newer version (IE 9 at this time) supports insertion of wrong HTML code via script so your HTML fragment won’t cause an error (even if it’s still not valid HTML).

    My suggestion is to insert only valid HTML:
    You may change the container element from <p> to <div>
    -or-

    You may change the inserted element from <div> to <span>

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

Sidebar

Related Questions

This code works... $(document).ready(function(){ $('body').css('background','black'); }); but this code doesn't... $(document).ready(function(){ $('thumb_slider').css('background','black'); }); ^^^the
I have the following code: <body> <div id=container style=position:absolute; left:0px; top:0px; z-index:1;> <div id=div1
What's wrong with this code? Why doesn't it show value? <script> $(document).ready(function() { $('#radio_div').change(function(event){
I am using the current code: $('body').mousedown(function() { $('div#extras').fadeTo('fast', 1); }); $('body').mouseup(function() { $('div#extras').delay(2000).fadeTo(1500,
Here's my code, why won't it fill the input text box? <html> <head> <script>
CSS code body { background-attachment: scroll; background-clip: border-box; background-color: #ececec; background-image: none; background-origin: padding-box;
This is my code: $('body').css('cursor','url(http://5211.91.tc/imcur/020.cur),auto'); Thanks
I have this background, the css code is: body { background: #FFF url('images/bg.png') no-repeat
I have a method called ReadTill that has the same body of code but
This code should i place this code at bottom of body it's in conditional

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.