this.window = new BrowserWindow({
transparent: true,
show: false,
width: 1920,
height: 1080,
frame: false,
autoHideMenuBar: true,
resizable: true,
// icon: path.join(__dirname, '../../build/icons/512x512.png'),
webPreferences: {
preload: path.join(__dirname, "src/controller/preload.js"),
webSecurity: false,
nodeIntegration: false,
contextIsolation: false,
enableRemoteModule: true,
},
});
this.window.webContents.openDevTools();
this.window.loadURL("https://www.kookapp.cn/app/login");
when i loadURL this url,return blank page.But others are normal.
why?
Is it because remote web pages are restricted?
I tested other domain names and other urls, which are normal, except the URL of this login page.
Related
I open a jQuery Modal Dialog. I open a second Modal Dialog after the first one closes. When the second one closes I cannot interact with my page any more. Seems that there is some modal dialog still alive.
Can someone help?
Thanks
function modalFirst_Set() {
$('#modalFirst').dialog({
autoOpen: false,
dialogClass: 'DynamicDialogStyle',
resizable: true,
draggable: true,
modal: true,
width: 400,
height: 120,
title: "My First Modal",
open: function (type, data) {
var Page = 'PageFirst.aspx';
$('#modalFirst').load(Page);
},
close: function (event, ui) {
var retValue = $('#modalFirst_RetValue').val();
if (retValue=='X')
modalSecond_Show();
$(this).dialog('destroy');
modalFirst_Set();
}
});
}
function modalSecond_Set() {
$('#modalSecond').dialog({
autoOpen: false,
dialogClass: 'DynamicDialogStyle',
resizable: true,
draggable: true,
modal: true,
width: 400,
height: 120,
title: "My Second Modal",
open: function (type, data) {
var Page = 'PageSecond.aspx';
$('#modalFirst').load(Page);
},
close: function (event, ui) {
$(this).dialog('destroy');
modalSecond_Set();
}
});
}
No problem with this code. The problem was inside the pageSecond.aspx file.
im trying to open a link in a new browser window using a Electron App.
const test = () => {
const shell = window.require('electron').shell;
shell.openExternal("https://google.com");
}
When i do this, i get error "window.require is not a function"
I have ofcourse made my research on this, and found several "fixes" but none has worked for me. I have edited my webpack.config.js to this:
module.exports = {
configureWebpack: {
externals: {
'./cptable': 'var cptable'
},
resolve: {
fallback: {
'fs': false,
'crypto': false,
'path': false,
}
}
},
}
I have also made sure nodeIntegration enabled like so:
const mainWindow = new BrowserWindow({
width: 1280,
height: 720,
webPreferences: {
nodeIntegration: true
},
autoHideMenuBar: true,
resizable: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
```
still no success. any idea?
renderer.js - from your renderer send request.
const response = await window.electronAPI.openLinkPlease()
preload.js - you have this middleware where your request will receive to send to electron.
process.once("loaded", () => {
contextBridge.exposeInMainWorld('electronAPI', {
openLinkPlease: () => ipcRenderer.invoke('openLinkPlease'),
})
});
electron.js - here you will get your request to open and electron will open this url in your default browser.
First add at the very beginning const {shell} = require("electron"); to add shell capabilities and than after
preload: path.join(__dirname, 'preload.js'),
},
});
add
ipcMain.handle('openLinkPlease', () => {
shell.openExternal("https://google.com");
})
This is the screen how it works from my application
I have no idea what is happening here, basically I tried to print a document in electron using webContents.print, by silent print, but this error occurs and the printer only prints the document a single time, after that the print queue is filled with new orders, but the error still happening and the file is not printed.
Some code of what I am trying to do:
ipcMain.handle('imprimir', async (event, args) => {
console.log(args);
const ticket = new BrowserWindow({
width: 300,
height: 400,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false
}
});
ticket.loadFile('src/views/ticket.html')
.then(() => {
ticket.webContents.send('enviar-pedido', args);
var options = {
silent: true,
deviceName: 'HP Deskjet 2000 J210 series',
printBackground: true,
color: false,
margin: {
marginType: 'printableArea'
},
landscape: false,
pagesPerSheet: 1,
collate: false,
copies: 1,
/*pageSize: { height: 600, width: 353 }*/
}
ticket.webContents.print(options, (success, failureReason) => {
if (!success) {
console.log(failureReason);
}
console.log('Print Initiated');
ticket.close();
});
});
Note: I do not speak fluent English and this is my first question here, I am sorry if I commited some mistake.
I ran into this just the other day.
I determined the error does not appear with the BrowserWindow option
nodeIntegration: false
If you do not need nodeIntegration in the HTML loaded into the ticket window you should be able to turn this off.
I am working on MVC Views.
I want a pop up window after adding portal details,'Portal details' pop up is not working
and also want to reload grid with data.
$("#addPortalDetails").dialog({
resizable: false,
autoOpen: true,
height: 140,
width: 300,
title:"Portal Details",
modal: true,
buttons: {
Ok: function () {
$(this).dialog("close");
//reload grid with data
}
}
});
Thanks in advance
To reload grid and and popup window the code is
$("#addPortalDetails").dialog({
resizable: false,
autoOpen: true,
height: 140,
width: 300,
title: "Portal Details",
modal: true,
dialogClass: "noclose",
buttons: {
Ok: function () {
$(this).dialog("close");
$("#your_grid_id").setGridParam({datatype:'json'}).trigger('reloadGrid', [{ page: 1 }]);
}
}
});
First time here, and more of a web designer than programmer, so be gentle! ;o) Anyway, as the title suggests, I have a dialog window that's opened and within that, a datepicker. What I want it that, if the user opens the datepicker, and then clicks the dialog window's close button, the datepicker is also closed.
Here's what I've got at present:
<!--// Modal Windows -->
$.ui.dialog.defaults.bgiframe = true;
$(function() {
$('#advanced_search').dialog({
autoOpen: false,
width: 600,
height: 400,
modal: true,
resizable: false,
draggable: false,
title: 'Advanced Search',
});
$('.adv_search').click(function() {
$('#advanced_search').dialog('open');
});
});
<!--// Date Picker -->
$("#advanced_search .start_date").datepicker({
dateFormat: 'dd/mm/yy',
showButtonPanel: true,
duration: 0,
constrainInput: true,
showOn: 'button',
buttonImage: '/img/icons/50.png',
buttonImageOnly: true
});
$("#advanced_search .end_date").datepicker({
dateFormat: 'dd/mm/yy',
showButtonPanel: true,
duration: 0,
constrainInput: true,
showOn: 'button',
buttonImage: '/img/icons/50.png',
buttonImageOnly: true
});
But I'm a bit flummoxed as to how to do this. Anyone got any advice? It'd be much appreciated!
Thanks
Phil
Add the close callback to your dialog like this:
$(function() {
$('#advanced_search').dialog({
autoOpen: false,
width: 600,
height: 400,
modal: true,
resizable: false,
draggable: false,
title: 'Advanced Search',
close: function() {
$("#advanced_search .start_date").datepicker('hide');
$("#advanced_search .end_date").datepicker('hide');
}
});
$('.adv_search').click(function() {
$('#advanced_search').dialog('open');
});
});
Here's an all-inclusive approach that's slightly better, simpler selectors and the date pickers aren't created until the dialog is actually opened, so if a user never goes into it, less script running:
$(function() {
$('#advanced_search').dialog({
autoOpen: false,
width: 600,
height: 400,
modal: true,
resizable: false,
draggable: false,
title: 'Advanced Search',
close: function() {
$("#advanced_search .start_date").datepicker('hide');
$("#advanced_search .end_date").datepicker('hide');
},
open: function(event, ui) {
$(".start_date, .end_date", ui).datepicker({
dateFormat: 'dd/mm/yy',
showButtonPanel: true,
duration: 0,
constrainInput: true,
showOn: 'button',
buttonImage: '/img/icons/50.png',
buttonImageOnly: true
});
}
});
$('.adv_search').click(function() {
$('#advanced_search').dialog('open');
});
});