<BR> tag with innerHTML problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xoinki
    New Member
    • Apr 2007
    • 110

    <BR> tag with innerHTML problem

    hi all,
    I have a very large string with no space and i am putting that in a table cell.
    1) Problem is that it does not wrap if a string does not have space in between and i want to force wrap it since an ugly horizontal scrollbar is coming inspite of proper percentage width assigned to the respective <thead>.

    2) So a workaround which we found was to break the large string at regular intervals and add <BR> in between so that it wraps. but after assigning this string to an innerHTML it does not seems to recognise BR and string is rendered without <BR> in an improper manner.

    anybody has come across this type of problem?

    Please help

    waiting for your reply,
    Xoinki
  • mrhoo
    Contributor
    • Jun 2006
    • 428

    #2
    Break the string with spaces and it will wrap in the cell

    Code:
    function spaceWrap(str,n){
    	var A= [];
    	while(str.length>n){
    		A.push(str.substring(0,n));
    		str= str.substring(n);
    	}
    	return A.join(' ')+' '+str;
    }
    //test
    var str=document.do cumentElement.i nnerHTML.replac e(/\s+/g,'')
    spaceWrap(str,1 0);

    Comment

    Working...