Switch page use "location.href"


#1

hi:
there are more than one page in my project,when i use location.href=“xxx.html” switch page,there will be a flash of white screen.how do I avoid this white screen?


#2

Actually, you can’t avoid that. You’re effectively loading another page, just like in a web browser. And in web browsers, when you’re going to load another page, the current one has to be unpainted. That’s why you get the flash of white. It’s your page being unpainted so the next one can be loaded.

If it’s really a big deal (for my app it was), you can look into Single Page Applications, which are actually very suitable for Electron. And given it’s nature, many problems with SPAs like navigation aren’t present in Electron because it doesn’t use traditional browser controls.


#3

You can use window.location.assign(‘xxx.html’) instead of location.href=xxx.html


#4

thanks
I tested it, but it still has a white screen.


#5

ok
thank you


#6

for me window.location.assign() is working thanq fellahss