electron 點擊鏈接通過瀏覽器打開

默認點擊鏈接打開在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()
{

}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章