| azhar123 on Jul 11, 2001 at 9:37:58 AM | No Rating |
i modified the code slightly to cater for multiple line selection tab and shift+tab. not the best of code but here goes:
<SCRIPT> /* Copyright 2000 SiteExperts.com/ InsideDHTML.com, LLC This code can be reusedas long as the above copyright notice is not removed */ function CheckTab(el) { // Run only in IE // and if tab key is pressed // and if the control key is pressed if ((document.all) && (9==event.keyCode)) { // Cache the selection if (event.shiftKey) { el.selection=document.selection.createRange(); setTimeout("ProcessTab('" + el.id + "',true)",0) } else { el.selection=document.selection.createRange(); setTimeout("ProcessTab('" + el.id + "',false)",0) } } } function ProcessTab(id,shiftVal) { //var re if (shiftVal==false) { //tab only //re = /\r\n[^\t]/ // Insert tab character in place of cached selection if (document.all[id].selection.text.length!=0) { //more than one char selected xSelection=document.all[id].selection.text xSelection=String.fromCharCode(9)+xSelection for (var x=0;x |
| tonyj on Jul 12, 2000 at 6:28:28 AM | Rating: 3 |
With a slight modification to the code, you can use the tab key without the control key with only the one function. Even works in IE5 without returning to start of line. See code below.
<SCRIPT> /* Copyright 2000 SiteExperts.com/ InsideDHTML.com, LLC This code can be reusedas long as the above copyright notice is not removed */
function CheckTab(el) { // Run only in IE // and if tab key is pressed // and if the control key is pressed if ((document.all) && (9==event.keyCode)) { // Cache the selection el.selection=document.selection.createRange(); el.selection.text=String.fromCharCode(9) event.returnValue=false } }
</SCRIPT> <TEXTAREA ID=MyTabDemo ONKEYDOWN="CheckTab(this)" ROWS=20 COLS=20> Try using CTRL-TAB inside of this textbox. </TEXTAREA>
|
| mack on Jun 28, 2000 at 8:06:09 AM | Rating: 4 |
| works great for me. many people have been looking for a solution to this problem. simple solutions are always best. |
| sub on Jun 28, 2000 at 6:10:52 AM | No Rating |
| I also tried, and works for me, but the cursor goes to the start of line !? (IE 5.50.3825.1300) |
| Scott Isaacs on Jun 20, 2000 at 8:05:04 AM | No Rating |
Please make sure you are holding down the CTRL key when you press TAB. (I tested with the same build of IE 5 as listed below).
I also updated the text above the demo to try and make this clearer.
-Scott |
| mack on Jun 20, 2000 at 7:12:37 AM | No Rating |
| You need to hold down the control key to make it enter a tab character instead of shifting focus. Scott, you might want to update the text of the article. |
| KrizInBizz on Jun 20, 2000 at 2:22:10 AM | Rating: 1 |
| not working in IE5 |
| Christian on Jun 20, 2000 at 1:47:55 AM | No Rating |
| Hi, i tired it, and it is not working for me IE 5.00.2920 |