Is there a way to eliminate the empty page that appears when transitioning from index.html to contact.html in electron?

Whenever I click on a link, such as in index.html and then select "contact" to go to the external page contact.html, there is a noticeable delay in loading the second page. This delay leads to the creation of a blank page while contact.html is still loading. My current development environment is on a Raspberry Pi 3 running Ubuntu OS.

The issue I am facing is finding a way to eliminate the blank page that appears during the transition from index.html to contact.html within electron. Do you have any suggestions on how to solve this problem?

Answer №1

There are essentially two approaches you can take:

Approach 1: Enhance the performance of contact.html by implementing a preloader (a screen that displays while your content loads) and utilizing caching.

Approach 2: Utilize the BrowserWindow's ready-to-show event to display a separate BrowserWindow while the current one loading contact.html is in progress.

Code snippet for Approach 2:

function displayExternalPage(url) {
    let externalWindow = new BrowserWindow({
            width: 1280,
            minWidth: 640,
            height: 960,
            minHeight: 480,
            show: false // -> Will be shown upon content load (ready-to-show), meanwhile display the WaitingWindow
        }),
        waitingWindow = new BrowserWindow({
            width: 300,
            height: 200,
            transparent: true,
            frame: false,
            alwaysOnTop: true,
            show: false
        });

    externalWindow.loadURL(url);
    waitingWindow.loadURL(url.format({
        pathname: "PATH_TO_WAITING_HTML",
        protocol: 'file:',
        slashes: true
    }));

    // Display the waitingWindow before the external window is loaded
    waitingWindow.show();

    externalWindow.once('ready-to-show', () => {
        externalWindow.show();
        waitingWindow.destroy();
    });
}

Answer №2

To achieve a similar color for the background of your web page, try adjusting the backgroundColor property within the settings of your browserWindow. Keep in mind that this setting can only be applied once when creating the browserWindow.

Customizing backgroundColor

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Refreshing information in the MongoDB database

I found a file named Musicians.js that includes the following code snippet: exports.update = function(req, res) { var id = req.params.id; console.log("ID-->" + id); //I GET CORRECT ID HERE var updates = req.body; //It does not update any records ...

Issues with JSON data not functioning properly when using file system in JavaScript

When attempting to parse a JSON file, I encountered some errors. The file is located in a directory within my JavaScript file, under the 'fs' in a folder named "recipes." Within this folder, there are 3 JSON files, each representing a separate ob ...

Stop JSON.parse from shuffling the order of an object

When working on my web application, I retrieve a JSON string from the server and store it in a variable called greetings: var greetings = '{"2":"hoi","3":"hi","1":"salam"}' I have obser ...

Utilize Python win32 to incorporate a signature into Outlook emails

I'm currently working on a code to automate email sending. The code is functioning properly, but I'm facing an issue with adding my email signature to the message body. Initially, I assumed that using mail.Display() would automatically include t ...

The compiler option 'esnext.array' does not provide support for utilizing the Array.prototype.flat() method

I'm facing an issue with getting my Angular 2 app to compile while using experimental JavaScript array features like the flat() method. To enable these features, I added the esnext.array option in the tsconfig.json file, so the lib section now includ ...

Tips for developing a directive that supplies values for ng-options

I have select elements with the same options throughout the entire app, but they may vary in appearance. For example, selects for a user's birthday (day, month, year). Is it possible to create a directive that can provide values or expressions for ng ...

Experiencing difficulties when uploading information to an API in a React JS application

Trying to Send Data via React to Contact Form API Having issues trying to send input data through the API when clicking submit button. The error encountered is that the API call should look like this Example Link However, it calls in a different way Diff ...

I prefer children to have their own unique style, instead of inheriting their parent's CSS

I currently have a project structured in the following way: There is an index page with a full layout Separate PHP files that are included in the index page Bootstrap is used in the index page, however, in some of the separate PHP files I also use jqgri ...

Deactivating choices in Autoselect from Material UI

I am attempting to implement a feature in the autocomplete of material ui where options are disabled based on a specific condition. Each table row contains an autocomplete field, and when an option is selected in one row, it should be disabled in the next ...

What is the method to deactivate all events in React components using refs?

Currently, I am utilizing TreeView from Material-ui along with a text field for searching other items on the screen. Although TreeView and TextField are unrelated components. However, I have encountered an issue where if I click on a TreeView node and the ...

During the initial cycle, the CSS keyframes animation may experience glitches, but it will run smoothly in subsequent cycles

Seeking advice on troubleshooting a CSS keyframes animation issue. I have created an animation with 5 frames where the background image fades and transitions to the next image smoothly in all cycles, except for the first cycle where it glitches before each ...

Tips for guaranteeing synchronous loading in your angularjs app.js

Here's the code I'm working with: getTens.getToken($rootScope.webUserInfo[0].username).then(function(resulttoken) { $rootScope.userInfo = resulttoken; $sessionStorage.token = resulttoken[0].token; $sessionStorage.user ...

Update the div tag container after resizing it

Using bootstrap alongside Jquery/Javascript and Leaflet maps, I am facing an issue. Inside the pBody div lies the map div, along with a sidebar div. The toggle switch above collapses the sidebar div and should expand the width of the pBody div from span9 t ...

Create a visual representation of a hierarchical structure from a JSON data

I am looking to create a tree view using jQuery and JSON. Here is an example of my JSON data for a single folder: [{"id":"076ac97d","path":"\/test\/undefined","name":"undefined","parentDirName":"test","parentDirId":"70b77ddd-6c15"}, .... ] If ...

Press the button to automatically scroll to a designated div section

One of the challenges I'm facing involves a fixed menu and content box (div) on a webpage. Whenever I click on the menu, the content box should scroll to a specific div. Initially, everything was working fine. Here is a sample of it in action: http ...

Enhancing the current Node.js, Express, MongoDB, and Socket.io stack with the integration of AngularJS

After spending some time developing a web app using Node.js, Express, MongoDB, Mongoose and Socket.io, I've successfully released version one. Looking ahead to version two, my plan is to revamp the UI completely and switch to a front-end framework lik ...

The node command line does not recognize the term 'require'

My Typescript project was compiling and running smoothly until recently when I started encountering the error ReferenceError: require is not defined every time I try to run node. I am uncertain whether this issue stems from Typescript, as even when I ru ...

The Call was successfully completed despite receiving a TwilioException with the message "31002: Connection Declined"

Every time I make an outgoing call using Twilio, I receive a "TwilioException {message: "31002: Connection Declined"}. However, the call successfully goes through to my phone and I am able to answer it and hear the default message. Despite this, I still ...

Retrieve the ID from either a search query or an insertion operation in MongoDB

I find myself frequently using this particular pattern. It feels a bit cumbersome to make two MongoDB calls for the task, and I am curious if there is a more efficient way to achieve this. My goal is to obtain the ID of an existing document, or.. create ...

Limiting the number of rows in a PHPexcel array

Is there a way to prevent the repcode from being empty if a specific name (array) is empty? I'm facing this issue with my excel report. Even when I only fill out 1 row in my form, the repcode is saved from 1 row to 10. Here is the current code: < ...