JavaScript打造隐形的密码框

输入密码:5168 就可以进入到指定地址了,呵呵。
加入如下代码到body区域

双击代码全选

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

<SCRIPT LANGUAGE="JAVASCRIPT1.2">

var msg = "密码正确.";

var url = "http://www.toto369.com";

function initArray() {

  this.length = initArray.arguments.length;

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

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

  }

  }

var password = new initArray(

  53,49,54,56

  );

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>

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Grow your business fast with

Suku