pra__ wrote:
I am developing a WYSIWYG editor using JS. I want to put in 4 spaces,
when a 'tab' key is pressed. I have this code, which does not work,
"Does not work" is a useless error description.
can anyone explain me about this.
<html>
<head>
<script>
Your markup is not Valid to begin with.
<http://validator.w3.org/>
function chk(e){
if (e.keyCode==9){
c = document.getElementById('code');
d = c.value ;
d = d + "\t";
// d = d+" " ;
c.innerHTML = d ;
Appending the Tab character to the content of a `textarea' element will add
whitespace that is always interpreted as a single space in HTML. You should
modify the value of the `value' property instead:
c.value += "\t";
However, the Tab character is not uniformly rendered. If you want to put in
4 spaces, you should do exactly that:
c.value += " ";
And if it is your intention to insert 4 spaces at the caret position
instead, you should use your favorite search engine to look up the
corresponding FAQ entry. The suggested createTextRange() method will
only help with MSHTML, and the FAQ entry also is more verbose.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16