PDA

View Full Version : [DHTML] Password script using Hotkey script.



Master_script_maker
06-27-2007, 10:24 PM
1) CODE TITLE: Password Script

2) AUTHOR NAME/NOTES: Master_script_maker

3) DESCRIPTION: A password script that uses the Hotkey script here. (http://www.dynamicdrive.com/dynamicindex5/button1.htm)

4) URL TO CODE: Here is the demo. (http://test10.freehostia.com/hi.html)

or, ATTACHED BELOW (see #3 in guidelines below):

thetestingsite
06-27-2007, 10:33 PM
Doesn't work in FF.

Master_script_maker
06-27-2007, 10:35 PM
I thought it would. Oh well.

Twey
06-27-2007, 10:41 PM
Hmm... nicer to write it like:
(function() {
var realpass = "password",
page = "example.html";

var w = "", r = new RegExp("[a-zA-Z0-9" + realpass + "]");
document.onkeypress = function(e) {
var v = e || event,
c = String.fromCharCode(v.charCode || v.which);
if(r.test(c))
if(realpass === (w = w + String.fromCharCode(c)))
location.href = page;
else if(realpass.substr(0, w.length) !== w)
w = "";
};
})();And yes, browsers tend to intercept various keys. It shouldn't be relied on anyway, though, so that's not really a problem; it's just a toy.