Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to disable the user's "TAB" key w/ javascript?

Status
Not open for further replies.

toefuzzies

Technical User
Dec 12, 2003
27
US
I have a page with secret links in it. Obviously the user could just tab through the page hitting the enter key each time to find where the secret link was. I don't want to allow the user to do this (only for a particular page). Even if there's a workaround like making the user go to another page when they click "TAB" that would be fine too.

Any ideas?
 
<A href="blah.htm"... TABINDEX=-1>

If this doesn't work: use onkeydown event on BODY tag, check for key code. If user pressed tab (code 9), return false.
 
I actually found something just now that will work. Thanks!!! - - It just tells the user they hit the TAB key. I can take it somewhere from there.

<script>
document.onkeydown = function(){

if(window.event && window.event.keyCode == 9)
{ // Capture and remap TAB
window.event.keyCode = 9;
}

if(window.event && window.event.keyCode == 9)
{ // New action for TAB
alert('The TAB key was pressed');
return false;
}
}

</script>
 

Good solution. However, surely people can just "view source" and see the link? ;o)

You'd be better off not having the hidden links, and just going direct to non-published URLs, I'd say.

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top