Recently, I faced the task of implementing the context menu on the right mouse click in the admin panel of one project. To solve this problem, I found a plugin for jQuery - contextMenu , demonstration . Looked at an example, downloaded, screwed and started checking. IE is fine, FF is fine, Safari is fine, Opera does not work!// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .
// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .// , if (navigator.appName.indexOf( "Opera" )!=-1){ // ( function (){ // , addEventListener( 'mousedown' , function (e){ // - if ( e && e.button == 2 ){ cancelMenu(e); return false ; } }, true ); var overrideButton; function cancelMenu(e){ if (!overrideButton){ var doc = e.target.ownerDocument; overrideButton = doc.createElement( 'input' ); overrideButton.type= 'button' ; (doc.body||doc.documentElement).appendChild(overrideButton); } overrideButton.style= 'position:absolute;top:' +(e.clientY-2)+ 'px;left:' + (e.clientX-2)+ 'px;width:5px;height:5px;opacity:0.01' ; } })( true , 1000 ); } * This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/45626/
All Articles