javascript - Electron app with multiple tabbed browser windows connecting to https sites -
i trying create own version of http://meetfranz.com/ using electron.
the app should allow multiple urls such https://messenger.com/ , https://gmail.com/ visible , have tabbed interface.
i've tried both generating webview , browserwindow.
- webview can't seem load messenger (does not load login)
- browserwindow pops out of main window…
i tried earlier on iframes no-go.
any ideas on best way accomplish tabbed minimal browser interface allows cookies/https?
index.html
<html> <head> <style> webview { display: inline-flex; width: 800px; height: 600px; } </style> </head> <body> <form name="form"> <input name="input" placeholder="https://messenger.com/" value="https://messenger.com"> <button type="submit">submit</button> </form> <div class="tabs"> </div> <div class="webviews"> </div> <!--<webview src="https://messenger.com/" autosize="on" nodeintegration="on" disablewebsecurity="on" webpreferences="allowrunninginsecurecontent"></webview>--> <script type="text/javascript"> require('./app.js') </script> </body> </html>
main.js
const {app, browserwindow, browserview} = require('electron') app.on('ready', createwindow) function createwindow(){ let win = new browserwindow({ width: 1000, height: 600, height: 600, "node-integration": "iframe", // , line "web-preferences": { "web-security": false, "nodeintegration": false, } }) win.on('closed', () => { win = null }) win.webcontents.opendevtools() // load remote url //win.loadurl('https://github.com') // or load local html file win.loadurl(`file://${__dirname}/index.html`) /*win.webcontents.session.webrequest.onheadersreceived({}, (d, c) => { if(d.responseheaders['x-frame-options'] || d.responseheaders['x-frame-options']){ delete d.responseheaders['x-frame-options'] delete d.responseheaders['x-frame-options'] } c({cancel: false, responseheaders: d.responseheaders}) })*/ } //app.commandline.appendswitch('disable-web-security')
app.js
const {app, browserwindow, browserview} = require('electron').remote let tabs = document.queryselector(".tabs") let webviews = document.queryselector(".webviews") document.getelementsbytagname("form")[0].onsubmit = function(event){ //createwebview(form.input.value) createbrowserwindow(form.input.value) return false; } function createwebview(url){ let webview = new webview() webview.setattribute("autosize","on") webview.setattribute("nodeintegration","on") webview.setattribute("disablewebsecurity","on") webview.setattribute("webpreferences","allowrunninginsecurecontent") webview.src = url webviews.appendchild(webview) let tab = document.createelement("div") tab.textcontent = url tab.target = webview tabs.appendchild(tab) } function createbrowserwindow(url){ let win = new browserwindow({ width: 800, height: 600, y: 100, x: 100, webpreferences: { websecurity: false, nodeintegration: false } }) win.setmenu(null) win.on('closed', () => { win = null }) view = new browserview({ webpreferences: { nodeintegration: false } }) win.webcontents.opendevtools() // load remote url win.loadurl(url) }
<webview>
way if want have single window. it's lot better <iframe>
, because it's securely isolated app , runs in separate process.
see docs: https://electron.atom.io/docs/api/webview-tag/
if messenger.com doesn't load properly, should problem should addressing (e.g. inspect console messages, network log). follow instincts, first choice right one, it's making work.
Comments
Post a Comment