How does js disable page refresh and rewind?

Source: Internet
Author: User

How does js disable page refresh and rewind?

This article describes how to disable page refresh and rewind in js. Share it with you for your reference. The specific implementation method is as follows:

?

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

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

<Script language = "javascript">

// Disable the F5 key

Function document. onkeydown ()

{

If (event. keyCode = 116)

{

Event. keyCode = 0;

Event. cancelBubble = true;

Return false;

}

}

// Disable context menu

Function document. oncontextmenu ()

{

Return false;

}

// The following Code enables full screen display

Function window. onload (){

Var Request = new Array (); // Save the Parameter

Var s = location. search. substring (1 );

If (s & s! = ""){

Var list = s. split ("&");

For (var I = 0; I <list. length; I ++ ){

Var pair = list [I]. split ("= ");

If (pair [0] & pair [0]! = ""){

Request [unescape (pair [0])] = unescape (pair [1]);

}

}

}

Var fullscreen = Request ["fullscreen"];

If (fullscreen! = "Yes "){

Var file = self. location;

Var a = window. open ("about: blank", "", "fullscreen = yes ");

Self. opener = null;

Self. close ();

A. location = file + "? Fullscreen = yes ";

}

}

</Script>

<Script language = "Javascript"> <! --

// Shield right-click, Ctrl + N, Shift + F10, F11, F5 refresh, and return keys

// Author: meizz (plum blossom rain) 2002-6-18

Function document. oncontextmenu () {event. returnValue = false ;}

// Right-click the screen

Function window. onhelp () {return false}

// Shield F1 help

Function document. onkeydown ()

{

If (window. event. altKey )&&

(Window. event. keyCode = 37) | // mask Alt + direction key seek

(Window. event. keyCode = 39) // mask Alt + direction key →

{

Alert ("You are not allowed to use ALT + arrow keys to move forward or backward the webpage! ");

Event. returnValue = false;

}

/* Note: this does not really block Alt + direction keys,

Because when the Alt + direction key pop-up warning box is displayed, press and hold the Alt key,

With the mouse clicked off the warning box, this blocking method will become invalid. If

Which of the following methods does the master really block the Alt key. */

If (event. keyCode = 8) | // shield the unregeed deletion key

(Event. keyCode = 116) | // block the F5 refresh key

(Event. ctrlKey & event. keyCode = 82) {// Ctrl + R

Event. keyCode = 0;

Event. returnValue = false;

}

If (event. keyCode = 122) {event. keyCode = 0; event. returnValue = false ;}

// Block F11

If (event. ctrlKey & event. keyCode = 78) event. returnValue = false;

// Block Ctrl + n

If (event. shiftKey & event. keyCode = 121) event. returnValue = false;

// Block shift + F10

If (window. event. srcElement. tagName = "A" & window. event. shiftKey)

Window. event. returnValue = false;

// Block shift and use the left mouse button to open a new webpage

If (window. event. altKey) & (window. event. keyCode = 115 ))

// Block Alt + F4

{

Window. showModelessDialog ("about: blank", "", "dialogWidth: 1px; dialogheight: 1px ");

Return false;

}

}

</Script>

I hope this article will help you design javascript programs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.