function breakWord(dEl){
if(!dEl || dEl.nodeType !== 1){
return false;
} else if(dEl.currentStyle && typeof dEl.currentStyle.wordBreak === 'string'){
breakWord = function(dEl){
dEl.runtimeStyle.wordBreak = 'break-all';
return true;
}
return breakWord(dEl);
}else if(document.createTreeWalker){
var trim = function (str) {
str = str.replace(/^ss*/, '');
var ws = /s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
breakWord = function(dEl){
var dWalker = document.createTreeWalker(dEl, NodeFilter.SHOW_TEXT, null, false);
var node,s,c = String.fromCharCode('8203');
while (dWalker.nextNode())
{
node = dWalker.currentNode;
s = trim( node.nodeValue ) .split('').join(c);
node.nodeValue = s;
}
return true;
}
return breakWord(dEl);
}else{
return false;
}
}
转自: http://www.hedgerwow.com/360/dhtml/css-word-break.html