Monitor for Password

[Total: 0    Average: 0/5]

Secretly monitor for keys to be entered (password).

Head Code:

<SCRIPT> 
var password    = "javascript";
var targetURL   = "/js/";
var charsEntered = 0; /* start with nothing entered */

var isIE5=document.all;
var isNS4=document.layers;
var isIE6=document.getElementById && isIE5;
var isNS6=document.getElementById && ! isIE6;

function getKey(keyStroke) { 
  var eventChooser = (isNS4||isNS6) ? keyStroke.which : event.keyCode; 
  var which = String.fromCharCode(eventChooser).toLowerCase(); 
  if (which == password.charAt(charsEntered))
  {
    charsEntered++; 
    if (charsEntered == password.length)
      window.location = targetURL; 
  } 
  else
  {
    charsEntered = 0;
  }
  document.f1.t1.value=charsEntered;
}
document.onkeypress = getKey; 
</script> 

Body Code:

type the word "<b>javascript</b>"
<BR>Note: Focus must be on the window for it to know keys have been typed.
<!--
  -- This following form is here only to show you when it determines correct letters have been entered.
  -- Change the type=text to type=hidden to not have this displayed.
  -->
<form name=f1>
<input type=text name=t1 value='-1'>
</form>

Times Viewed: 5

Leave a Reply

Your email address will not be published. Required fields are marked *