View Single Post
Old 04-11-2008, 08:30 PM   #11 (permalink)
TlcAndres
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

Quote:
function stoptab(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
var el = document.getElementById('css_text');
if ((evt.keyCode == 9)) {
var oldscroll = el.scrollTop;
evt.returnValue=false;
if (el.setSelectionRange) {
var pos_to_leave_caret=el.selectionStart+4;
el.value = el.value.substring(0,el.selectionStart) + '\t' + el.value.substring(el.selectionEnd,el.value.length );
}else{
document.selection.createRange().text='\t';
}
el.scrollTop = oldscroll;
return false;
}

}

document.onkeypress = stoptab;
The only downside is it works when ever it presses tab but thats the only version, the new one just has the addons to see if it's focused on the textbox
__________________
"What everyone seems to forget is that while knowledge certainly is something - it's the implementation of knowledge that brings power" - Andres Galindo.
TlcAndres is offline  
Reply With Quote
The Following User Says Thank You to TlcAndres For This Useful Post:
sidisinsane (10-31-2008)