text - Javascript color split string -
i'm using following code process strings when gets down innerhtml part want color tittxt0 variable string data blue. know how if dom element don't know how color tittxt0 variable data , leave limit chars0 alone. time.
var tittxt0 = txt0[i].split("++++")[0]; var txt00 = txt0[i].split("++++")[1]; var limitchars0 = txt00.substring(0,100); var limitchars1 = txt00.substring(100, txt00.length); var codecou0=limitchars1.split("[code]"); if(codecou0.length>1){paras0[i].innerhtml ="[code]" } if(limitchars0.length ==80){ paras0[i].innerhtml += tittxt0+"<br>"+limitchars0+ " ..."; tittxt0.style.color="blue"; }else{ paras0[i].innerhtml += tittxt0+"<br>"+limitchars0; tittxt0.style.color="blue"; }
i fixed issue makeing on varaiable inside paragraph , inserting other variable inside strong element here complete function whoever needs it.
callrecb0:function(rectxt){ var forumcon0 = document.getelementsbyclassname("forumcon0"); var txt0 = rectxt.split(":::"); for(var i=0; i<txt0.length; i++){ var newpara0=document.createelement("p"); forumcon0[0].appendchild(newpara0); var paras0=forumcon0[0].getelementsbytagname("p"); paras0[i].setattribute("id", "x"+i); custevents.addevent(paras0[i], 'click',custevents.forlink0); var tittxt0 = txt0[i].split("++++")[0]; var txt00 = txt0[i].split("++++")[1]; var limitchars0 = txt00.substring(0,35); if(limitchars0.length==35){ var limitchars00 = txt00.substring(36,71); }else{ limitchars00=""; } var limitchars1 = txt00.substring(71, txt00.length); //var limittotatl0 = limitchars0.length+limitchars00.length; //alert(limittotal0); //paras0[i].innerhtml += tittxt0+"<br>" paras0[i].style.color="blue"; var codecou0=limitchars1.split("[code]"); if(codecou0.length>1){paras0[i].innerhtml ="[code]" } if(limitchars00.length >34){ paras0[i].innerhtml += tittxt0+"<br>" paras0[i].style.color="blue"; var newpara1=document.createelement("strong"); paras0[i].appendchild(newpara1); newpara1.style.color="black"; newpara1.innerhtml+=limitchars0+"<br>"+limitchars00+" ..."; }else{ paras0[i].innerhtml += tittxt0+"<br>" paras0[i].style.color="blue"; var newpara1=document.createelement("strong"); paras0[i].appendchild(newpara1); newpara1.innerhtml+=limitchars0+"<br>"+limitchars00; newpara1.style.color="black"; } if(i==txt0.length-2){ formstyle.odd(); } } },
Comments
Post a Comment