• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

420
Views
¿Cómo cambiar el archivo html usado en Electron?

Estoy tratando de cambiar el archivo html utilizado en la aplicación Electron. Probé varias sugerencias aquí en StackOverFlow, pero no puedo lograr nada. Mi código es el siguiente:

principal.js:

 <!DOCTYPE html> <html> <head> <script src="renderer.js"></script> </head> <body> <h1>One</h1> <button id="change">Change</button> </body> </html>

nuevo.html:

 <!DOCTYPE html> <html> <head></head> <body> <h1>Two</h1> </body> </html>

principal.js:

 const { app, BrowserWindow } = require('electron') const path = require('path') function createWindow () { // Create the browser window. const mainWindow = new BrowserWindow({ width: 800, height: 600 }) mainWindow.loadFile('index.html') mainWindow.openDevTools(); } app.whenReady().then(() => { createWindow() app.on('activate', function () { if (BrowserWindow.getAllWindows().length === 0) createWindow() }) })

renderizador.js:

 const {BrowserWindow} = require('electron').remote const path = require('path') const newWindowBtn = document.getElementById('change') newWindowBtn.addEventListener('click', (event) => { let win = new BrowserWindow({ width: 400, height: 320 }) win.on('close', () => { win = null }) win.loadFile("new.html"); })

Estoy tratando de cambiar el archivo html a new.html una vez que uno hace clic en el botón en index.html.

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

puede usar location.href='new.html' en esta función para cambiar de página en una ventana.

almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error