admin管理员组文章数量:1130349
默认点击链接打开在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()
{
}
默认点击链接打开在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()
{
}
版权声明:本文标题:electron 点击链接通过浏览器打开 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/jiaocheng/1726855229a674334.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论