2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-16 01:37:07 +00:00

Fix #8 user agent issue

The user agent needs to be set for the `<webview>` instead of for the `mainWindow`
This commit is contained in:
Jia Hao 2016-01-19 18:06:20 +08:00
parent 8ad805d820
commit 5adf7b9297
2 changed files with 5 additions and 1 deletions

View File

@ -16,6 +16,10 @@ ipc.on('params', function(event, message) {
webView.setAttribute('minwidth', '100'); webView.setAttribute('minwidth', '100');
webView.setAttribute('minheight', '100'); webView.setAttribute('minheight', '100');
webView.addEventListener('did-start-loading', function() {
webView.setUserAgent(appArgs.userAgent);
});
webView.addEventListener('new-window', function(e) { webView.addEventListener('new-window', function(e) {
require('shell').openExternal(e.url); require('shell').openExternal(e.url);
}); });

View File

@ -39,7 +39,7 @@ app.on('ready', function() {
mainWindow.openDevTools(); mainWindow.openDevTools();
} }
mainWindow.loadUrl('file://' + __dirname + '/index.html', { userAgent: appArgs.userAgent}); mainWindow.loadUrl('file://' + __dirname + '/index.html');
mainWindow.webContents.on('did-finish-load', function() { mainWindow.webContents.on('did-finish-load', function() {
mainWindow.webContents.send('params', JSON.stringify(appArgs)); mainWindow.webContents.send('params', JSON.stringify(appArgs));