如何在电子邮件地址中添加协议,如'//abc.com'?
问题描述:
现在,像'//abc.com'这样的网址,电子会自动重定向到'file://abc.com'。有没有办法将https
协议头添加到该网址而不是file
?如何在电子邮件地址中添加协议,如'//abc.com'?
答
const shell = require('electron').shell;
webContents.on('new-window', function(event, url){
event.preventDefault();
if (url.startsWith('//')) {
url = 'https:' + url;
}
shell.openExternal(url)
});
感谢您的评论!我的情况有点不同,我有一些资源在创建窗口后会被请求,如何强制所有外部资源加载同步或异步通过“https”? – Blake