DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2007
    Posts
    2

    Converting JS DOM objects into HTML for IE

    OK, so it is kind of easy to dynamically create content using document.createElement() and appendChild() methods in Firefox for an xhtml document.

    The thing is, IE does not act on them. I can only set innerHTML to something, IE seems to ignore appendChild(). This makes me to generate actual HTML from js.

    This works in FF, not in IE:
    Code:
      var mirenglon = document.createElement('tr');
      var fechacol = document.createElement('td');
      var letrecol = document.createElement('td');
      fechacol.setAttribute('id','columna_'+i);
      letrecol.setAttribute('id','renglon_'+i);
      fechacol.className='coursedata_date';
      letrecol.className='coursedata_fecha';
      mirenglon.appendChild(fechacol);
      mirenglon.appendChild(letrecol);    
    
      document.getElementById('coursecal_table').appendChild(mirenglon);
      document.getElementById('columna_'+i).innerHTML = fecha;
      document.getElementById('renglon_'+i).innerHTML = letrero;
    So the questions are

    1- Is there a way to make IE "understand" that I am actually trying to modify the document's DOM?

    2- if not, is there a way to "convert" an object created by createElement() into HTML so that I can then update the page using innerHTML?

  2. #2
    Join Date
    Apr 2007
    Posts
    2
    My mistake was that I was trying to append rows to a table object, instead of a tbody object. Now it works in both browsers.

    I think I had the wrong question.

Similar Threads

  1. Code for converting Text To HTML
    By HusamMc in forum .NET
    Replies: 6
    Last Post: 09-26-2006, 03:46 AM
  2. Accessing DOM Objects
    By nandoo in forum Web
    Replies: 0
    Last Post: 05-03-2005, 07:26 AM
  3. Replies: 2
    Last Post: 02-11-2001, 08:48 PM
  4. Replies: 0
    Last Post: 02-07-2001, 12:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links