How to solve unknown runtime errors when setting innerHTML in IE using Javascript _ javascript skills

Source: Internet
Author: User
The program code idea is roughly as follows. I want to dynamically change the innerHTML content of the tr tag, but IE reports an unknown runtime error. The Code is as follows:


Script
Document. getElementById ("trone"). innerHTML = "haha ";
Script



In IE, "unknown runtime error" may sometimes occur, but not in firefox.

This is mainly because when IE writes innerHTML, it will check whether the element meets the requirements of the html object container in the content. For example, if you add
  • . So if you find these errors occur, try to do two things:
    1. Check whether the html code you tried to add to innerHTML contains broken html tags. If not
      Surrounded
    • .
      2. Change your container to the "inclusive" labels, for example,


      Note that,
      , Add the correct format to the tag Use document. getElementById ("trone"). innerHTML = "new. Solution: You can use javascript to dynamically create
      Labels may have errors, so avoid using these labels as containers and use them if necessary. As a container, a layer of tables is nested.

      Therefore
      Instead of using innerHTML.
      Related Article

      Contact Us

      The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

      If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

      A Free Trial That Lets You Build Big!

      Start building with 50+ products and up to 12 months usage for Elastic Compute Service

      • Sales Support

        1 on 1 presale consultation

      • After-Sales Support

        24/7 Technical Support 6 Free Tickets per Quarter Faster Response

      • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.