...

View Full Version : Disable TAB key



StealthRT
11-12-2006, 09:15 AM
Hello all i am trying to disable the tab button when the user loads up my page mainly to prevent them to tab to buttons once a overlay is displayed and waiting on them to enter something before continuing.

Here is the code im trying to get work but for some reason it doesnt like the TAB key...


<script language="JavaScript1.2">
function keyPressed() {
var TABkey = 15;
if (event.keyCode == TABkey) {
var strMessage = "Hello, there. I will help you";
strMessage += " in understanding various parts of this page.";

var strWindowProperties = "toolbar=no,location=no,status=no,";
strWindowProperties += "menubar=no,scrollbars=no,resizable=yes,";
strWindowProperties += "width=160,height=20";

var win = window.open (win, 'window', strWindowProperties);
win.document.write (strMessage);
}
}
</script>
</head>


<body onKeyDown="keyPressed()">



Any help would be great! :)
David

Philip M
11-12-2006, 12:03 PM
var TABkey = 09;

Vladdy
11-12-2006, 04:02 PM
Logical solution would be disabling button elements until they are ready to be used.

StealthRT
11-12-2006, 08:12 PM
Thanks Philip M, changing the number worked...

Vladdy: Care to share what you are talking about when u say disabling button elements?

The code i had above works now but i am still able to tab through everything once the box has been open.. I want a way to disable it totaly until they leave the site...

David

Vladdy
11-13-2006, 12:05 AM
Per HTML 4.01 disabled elements are skipped in tabbing navigation (http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled)
When you display your ovelay run a function that disables all form elements and enable them again when the overlay is closed.

StealthRT
11-13-2006, 03:06 AM
Yeah vlad it gives no code reference so i have no idea on how to do what its saying.. :confused:

David

Vladdy
11-13-2006, 05:09 AM
function enableAllButtons(onOff) //where onOff is true to enable buttons, false to disable
{ var allBtns = document.body.getElementByTagName('button');
for(var i=0; i<allBtns.length; i++) allBtns[i].disabled = !onOff;
}

StealthRT
11-13-2006, 05:44 AM
What would be the tag name if i wanted the links on the page not to be clickable? Or is that possible?

ArcticFox
11-13-2006, 05:48 AM
LOL!


You may look at his page, but you may not touch it!

:D

StealthRT
11-13-2006, 05:53 AM
Yes correct :)

Im just trying to block anything for being clickabme if the overlay is on. Hints i can still click on stuff using the enter and tab key for this site even though its blocked with the mouse : http://www.pageflakes.com/

David

Vladdy
11-14-2006, 02:02 AM
function enablePage(onOff)
{ var formElements = ['button','input','select','textarea'];
for(var i=0; i<formElements.length; i++)
{ var elms = document.body.getElementByTagName(formElements[i]);
for(var j=0; i<elms.length; i++) elms[i].disabled = !onOff;
}
var links = document.body.getElementsByTagName('a');
for(var i=0; i<links.length; i++)
links.onclick = onOff?null:function(){return false;};
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum