最近、1つのプロジェクトの管理パネルに右クリックコンテキストメニューを実装するというタスクに直面しました。 この問題を解決するために、jQueryのプラグイン
-contextMenu (
デモ )を見つけました。 私は例を見て、ダウンロードし、それをねじ込み、チェックし始めました。 IE-通常、FF-通常、Safari-通常、Opera-動作していません!
そして、問題は次のとおりです。Operaでは、独自のコンテキストメニューを作成してマウスの右クリックを追跡することはできません。
解決策:ご存じのとおり(または知らない)、OperaにはJavaScript設定(ツール-設定-詳細-コンテンツ-JavaScript設定)があり、「右マウスボタンの制御を許可する」というプロパティがあります。 クリックすると結果が得られます-JSは右クリックイベントをキャッチしてコンテキストメニューを表示しますが、その上に標準メニューが表示されます。 少しグーグルは彼の問題の解決策を見つけました:
// , 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 .
スクリプトは、標準のOperaコンテキストメニューを隠すボタンをページに作成します。 このスクリプトを管理パネルにねじ込んで
、次のものを
入手しました (Operaを参照)。 今、私はそれを喜んで使っています。
PS不必要な質問を避けるために、スクリプトは管理パネルでのみ使用されるため、右クリックトラッキングを有効にするようユーザーに求めることは怖くないと考えられていました。