Next, I will introduce you to a simple implementation method of disabling pop-up by right-clicking the IE browser menu. For more information, see.
Add the oncontextmenu event to the tag. To prevent event propagation and prevent the system from right-clicking the menu. So I did this:
| The Code is as follows: |
Copy code |
|
Var e = evt | window. event;
If (e. preventDefault ){
E. preventDefault ();
}
If (e. stopPropagation ){
E. stopPropagation ();
} Else {
E. cancelBubble = true;
} |
It's okay in IE9, IE10, FireFox, and Chrome.
However, in IE8, right-click the system and the custom menu and System menu are displayed.
After searching for relevant information, you need to add a statement to prevent the context menu pop-up in IE8 and IE7:
| The Code is as follows: |
Copy code |
|
E. returnValue = false; |
After the modification, my code is as follows:
| The Code is as follows: |
Copy code |
|
Var e = evt | window. event;
If (e. preventDefault ){
E. preventDefault ();
}
If (e. stopPropagation ){
E. stopPropagation ();
} Else {
E. returnValue = false; // right-click IE8 to pop up
E. cancelBubble = true;
} |
Solve the problem. In fact, e. returnValue can prevent the pop-up of the right-click system menu of IE browsers.