hi all,
i am a javascript, programming newbie. i use the password(cookie) script in [url]http://www.javascript-page.com/cright.html[url]http://pajhome.org.uk/crypt/md5
in ie6, if i press “cancel” in the password prompt, it says ‘length’ is null or not an object then break the script and go to the portected page.
here is the script;
[QUOTE]
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (“;”, offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + “=”;
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(” “, i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + “=” + escape (value) +
((expires == null) ? “” : (“; expires=” + expires.toGMTString())) +
((path == null) ? “” : (“; path=” + path)) +
((domain == null) ? “” : (“; domain=” + domain)) +
((secure == true) ? “; secure” : “”);
}
function DeleteCookie(name) {
var exp = new Date();
FixCookieDate (exp);
exp.setTime (exp.getTime() – 1);
var cval = GetCookie (name);
if (cval != null)
document.cookie = name + “=” + cval + “; expires=” + exp.toGMTString();
}
var d = GetCookie(“de”)
var paswd = “a9993e364706816aba3e25717850c26c9cd0d89d”
if (d == paswd) {}
if (d == null || d != paswd) {
check_in()
}
function check_in(){
var f = prompt(“Enter password to proceed.”,””);
[COLOR=Red]var h = hex_sha1(f);
var thenewdate = new Date ();
thenewdate.setTime(thenewdate.getTime() + (365 * 24
SetCookie(‘de’,[COLOR=Red]h
var e = GetCookie(‘de’);
if (e == paswd) {}
else {
location = “http://www.google.com”
}
}