Why does <webview> reset it's zoomFactor on url navigate?


Hi! I set zoom to the <webview> tag with code:
The zoom is applied but when I click link inside of the <webview> tag zoom is immediately resetted to 1.0.
I made event handler for the did-stop-loading event to fix zoom after load but zoom flickering during page load is visible and irritating.
How to force constant zoom factor?

electron v. 0.36.11

What is the correct way to set the initial zoomLevel of a webview?

This still happens in 1.3.0. I can’t imagine this is the designed behavior, is it?


A webview is essentially a browser tab inside the rest of the page. If I zoom in on a page in Chrome and then click a link to go to some other web page, the zoom factor doesn’t carry over. So yes, I assume that this is by design. It appears to save the zoom factor based on the domain of the URL?


In my understanding the zoomFactor (or zoomLevel) belongs to the webFrame, which is part of the Renderer, right? The webview is a child of the Renderer.

So why does the zoomFactor get reset when the webview is loading a new (or even the same) content?


The Brave browser doesn’t seem to have this issue.

When Brave changes the page zoom, it calls some methods on the webview with names like zoomIn(), zoomOut(), zoomReset(). These methods don’t exist in the mainstream version of Electron. I think the Brave people have added these to their own fork. I think this is the commit which adds them: “add zoom in/out/reset using host setting map”. Also related, “Expose zoom percentage”, made on the same day.

I’m not saying for sure that these changes were intended to fix the resetting zoom problem. I do see that Brave made these changes to their browser only a couple of weeks ago, and I just now reinstalled a 4 month old build of Brave that I happened to have on my computer and that does have the resetting zoom problem, unlike the current version.

Do the changes in Brave’s Electron fork tend to get merged into the official project? I hope so, in this case.


Seems that Brave try to at least keep their fork up to date. If you’re really keen on Brave’s changes, you could always give their fork a go instead.