私は新しいプロジェクトに取り組んでいます。ユーザーのデスクトップアプリケーションを作成したいと思います。私はAtom Electronフレームワークを選択します。Atom Electron webview contextmenu、クリックターゲットを取得
問題は、webview要素にカスタムコンテキストメニュが必要なことです。
これまでのところ、私はwebviewでコンテキストメニュを作成することができますが、クリックの「下」のコンテンツにはアクセスできません。 :)
のindex.html:右クリックが発生したときに
<webview id="webViewDefault" class="active" src="http://example.com" minwidth="100%" minheight="100%" partition="somePartition" nodeintegration allowpopups></webview>
renderer.js
const electron = require('electron');
const Menu = electron.remote.Menu;
//Create contextmenu template
const WebViewMenu = Menu.buildFromTemplate([{
label: 'Button 1', click(){
console.log('Button 1 clicked');
}
},
{type: 'separator'}, {
label: 'Button 2', click(){
console.log('Button 2 clicked');
}
}
]);
//get webview
let defaultWebview = document.getElementById("webViewDefault");
//add event listner
defaultWebview.addEventListener("contextmenu", (event) => {
const t = event.srcElement.id.split('-');
WebViewMenu.popup(electron.remote.getCurrentWindow());
});
は、どのように私は、例えば、リンクのhref属性を取得することができますので、私は新しいを作成することができますタブをクリックします。私はただのリンクから、URLを取得する必要があります
タブなど、アクティブなものを選択し、新しいwebviewsを作成し、偉大な作業している...:D事前に助けを
ありがとう!