----------------------------------------------------------------------
<img src="images/wordwrap.gif" onclick="wordWrap();"><br>
<textarea id="editor" wrap="off">Content</textarea>
function wordWrap() {
var txtarea = document.getElementById('editor');
wrap = txtarea.getAttribute('wrap');
if (wrap.toLowerCase() == 'off') { /* this is line 8 */
txtarea.setAttribute('wrap', 'soft');
txtarea.setAttribute('id', 'editor');
var parNod = txtarea.parentNode, nxtSib = txtarea.nextSibling;
parNod.removeChild(txtarea); parNod.insertBefore(txtarea, nxtSib);
}
else {
txtarea.setAttribute('wrap', 'off');
txtarea.setAttribute('id', 'editor');
var parNod = txtarea.parentNode, nxtSib = txtarea.nextSibling;
parNod.removeChild(txtarea); parNod.insertBefore(txtarea, nxtSib);
}
}
----------------------------------------------------------------------
By default, the textarea wrap is set to "off". If I then click
wordwrap.gif, the wrap is actually set "soft". But if I click again, the
wrap doesn't change back into "off". FireFox generates the following error:
Error: wrap has no properties
Source File: http://192.168.0.2/cms/system/js/editor.js
Line: 8
Secondly, IE doesn't respond to this script at all.
-> What am I missing here? As far as I know, this script should work. It
might be a bit dirty, but that's because I have to work around the
FireFox bug. Any help would be greatly appreciated!
Cheers, Dennis
<script type="text/javascript">
function wordWrap() {
var txtarea = document.getElementById('editor');
wrap = txtarea.getAttribute('wrap');
(wrap.toLowerCase() == 'off')?
txtarea.setAttribute('wrap', 'soft'):
txtarea.setAttribute('wrap', 'off');
/*Fix display for mozilla*/
txtarea.style.display='none';
txtarea.style.display='';
}
</script>
http://files.photojerk.com/files/files/1130186460/textareaWrap.htm
--
BootNic Monday, October 24, 2005 4:46 PM
A sense of humor is the lubricant of life's machinery.
*Unknown*
It worked on my FF 0.8.0, Mozilla 1.7.12 and IE6.
The only thing I seen that may make it appear not to work would be if
there is not enough text in the text area to change the appearance,
which would make it appear to do nothing.
Did you get the same results with the sample link?
http://files.photojerk.com/files/files/1130186460/textareaWrap.htm
In any case I have no other thoughts at the moment.
--
BootNic Monday, October 24, 2005 6:08 PM
Inform all the troops that communications have completely broken down.
*Ashleigh Brilliant*