默認點擊鏈接打開在electron的窗口
1、引入
const {shell}=require('electron').remote;
2、在事件中設置
e.preventDefault(); 阻止窗口打開的默認事件
let href=a.href;
shell.openExternal(href); 通過url在瀏覽器打開
代碼示例:
const {net,Menu,shell}=require('electron').remote;
var view=document.querySelector('.wb');
var sp=document.querySelector('.sp');
var btn=document.querySelector('.obtn');
var gbtn=document.querySelector('.gbtn');
var cbtn=document.querySelector('.cbtn');
var dbtn=document.querySelector('.dbtn');
var a=document.querySelector("#hre");
var proxy;
a.onclick=function(e){
e.preventDefault();
// let href=a.getAttribute('href');
let href=a.href;
shell.openExternal(href);
}
btn.onclick=function(){
}
gbtn.onclick=function(){
}
cbtn.onclick=function()
{
}
dbtn.onclick=function()
{
}