They say a little knowledge is a dangerous thing.
I'm trying to write a script that will allow users to toggle between word-wrap and no word-wrap. All my table cells are specified like this:
<TD><DIV class='wrap'>Here is text</DIV></TD>
By default my DIV.wrap style is { white-space: nowrap; }
I've tried to adapt an existing script so that it'll change the white-space from nowrap to normal but all it does is hang the browser. Any fixes would be gratefully received, and I'm happy to learn from this so if there's a better way of doing the same thing please let me know.
- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
I'm trying to write a script that will allow users to toggle between word-wrap and no word-wrap. All my table cells are specified like this:
<TD><DIV class='wrap'>Here is text</DIV></TD>
By default my DIV.wrap style is { white-space: nowrap; }
I've tried to adapt an existing script so that it'll change the white-space from nowrap to normal but all it does is hang the browser. Any fixes would be gratefully received, and I'm happy to learn from this so if there's a better way of doing the same thing please let me know.
Code:
function setwhitespacetonormal() {
var elements;
elements = document.getElementsByTagName('div');
for(var i = 0; i < elements.length; i++) {
var node = elements.item(i);
for(var j = 0; j < node.attributes.length; j++) {
if(node.attributes.item(j).nodeName == 'class') {
if(node.attributes.item(j).nodeValue == 'wrap') {
node.style.whitespace = 'normal';
}
}
}
}
}
- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments