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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:44:51+00:00 2026-06-02T05:44:51+00:00

Using this strips my newLine characters Is there an alternative to this that will

  • 0

Using this strips my newLine characters

Is there an alternative to this that will render html?

 function viewCommentToggle( comment )
{
    theRow = document.getElementById("id"+comment.id);

    idx = 2;


        // Comment field
        cell = theRow.cells[idx];
        while( cell.childNodes.length > 0 ) cell.removeChild(cell.childNodes[0]);

            element = document.createTextNode(comment.comment);

        cell.appendChild(element);


         }

This is what Im concered with:

element = document.createTextNode(comment.comment);

just a fyi….this is what I did and it worked:

    function viewCommentToggle( comment )
{
    theRow = document.getElementById("id"+comment.id);

    idx = 2;


        // Comment field
        //cell = theRow.cells[idx];
        // while( cell.childNodes.length > 0 ) cell.removeChild(cell.childNodes[0]);

        cell = $("#id"+comment.id+" > td:eq("+idx+")");
        $(cell).empty();

        $(cell).html( comment.comment == null ? "" : comment.comment.replace(/\n/g,"<br/>").replace(/\r/g,"") ); 
  • 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-02T05:44:52+00:00Added an answer on June 2, 2026 at 5:44 am

    Newlines are only significant (AFAIK) within a <pre> block.

    Outside of that, to force line breaks you’ll have to split your string into separate lines and then create a text node followed by a <br/> for each one, i.e. something like:

    var lines = text.split('\n');
    var parent = document.body; // the node you want to insert the string into
    for (var i = 0; i < lines.length; ++i) {
        parent.appendChild(document.createTextNode(lines[i]));
        parent.appendChild(document.createElement('br'));
    }
    

    See http://jsfiddle.net/alnitak/WFTD6/

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

Sidebar

Related Questions

I am using a YUI DataTable with a custom sortFunction that strips out HTML
Is there anyway easier than this to strip HTML from a string using Perl?
I'm using DOM to parse string. I need function that strips span tags and
Using this jquery code: <a href=javascript:void(0) id=m1>Get Selected id's</a> jQuery(#m1).click( function() { var s;
Using this code var html='<div class=somediv></div>'; var target=document.getElementById('contentArea'); target.appendChild(html); I'm getting Uncaught Error: NOT_FOUND_ERR:
Using this sample : I have make my own Fragment that holds tabhost and
This should be quite a simple problem, I've come across it enough that there
When using jQuery to insert HTML into a div in IE8, IE8 strips the
I'm using Stripes 1.5 and I was using a interceptor (based on this example
Using this file as source, I have a situation where I need to retrieve

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.