171、密码验证后导航

171、密码验证后导航

脚本说明:

把如下代码加入<head>区域中

abcd后回车<body><SCRIPT LANGUAGE="JAVASCRIPT1.2">

<!--密碼正確時所出現的提示//-->

var msg = "您輸入的密碼正確.";

<!--密碼正確後所進入的網頁連結/-->

var url = "http://www.7stk.com";

 

function initArray() {

       this.length = initArray.arguments.length;

       for (var i = 0; i < this.length; i++) {

              this[i] = initArray.arguments[i];

       }

}

<!--在這裡可以設定密碼﹐該密碼是以ASCII碼來表示的﹐比如A97B98等。//-->

var password = new initArray(

97,98,99,100

);

 

var pass_count=0;

 

var cancel_key=27;

if (document.layers)      document.captureEvents(Event.KEYPRESS)

function backhome(e){

       if (document.layers){

       //if (navigator.appName == "Netscape"){

              if (e.which==password[pass_count]) {

                     checkpassword();

                     //return false;

              }

              else {

                     pass_count=0;

                     //return false;

              }

       }

       else if (document.all){

              if (event.keyCode==password[pass_count]){

                     checkpassword();

                     //return false;

              }

              else {

                     pass_count=0;

                     //return false;

              }

                           

       }

}

 

 

document.onkeypress=backhome

 

function checkpassword() {

       pass_count++;

       if(pass_count>=password.length)  {

              if(confirm(msg))    window.location=url;

       }

}

</SCRIPT>

 

 

Write a comment

Comments: 0