I need to stop text from wrapping at a special character....if you set the innerHTML of some given element without setting the width of said element, it will set the size of the element to the width of the largess single word and wrap at white spaces....I've gotten that taken care of with when I don't want to wrap, but if you preset the size of the element to let the text wrap at the end of the element, it will also wrap at special characters (hyphen for example) and I'm not sure how to stop that. The method I am currently using seems like overkill, but let me know if you have any thoughts:
I fist replace all the white space in the string with non breaking spaces
Expand|Select|Wrap|Line Numbers
- var str=a.content.replace(/ /g,' ');
Expand|Select|Wrap|Line Numbers
- if(popup.Content.offsetWidth>200){
- var tmpStr=a.content
- var tmpTxt=tmpStr.split(/(\s\S+[^a-zA-z0-9\s]+\S+)/g)
- var newString=''
- for(i in tmpTxt){
- if((i%2)!=0){
- newString+='\n\r'+tmpTxt[i].substring(1);
- }else{newString+=tmpTxt[i]}
- }
- popup.Content.innerHTML=newString
- popup.Content.style.width=200+'px'
- popup.appendChild(popup.Content)
- }