May 25, 2021 Electron
web-frame
allows you to customize how the current web page is rendered .
Example, enlarge the current page to 200%.
var webFrame = require('electron').webFrame;
webFrame.setZoomFactor(2);
web-frame
module has the following methods:
webFrame.setZoomFactor(factor)
factor
Number - Zoom parameters.
Modify the zoom parameter to the specified parameter value. The scaling parameters are percentage, so 300% is 3.0.
webFrame.getZoomFactor()
Returns the current zoom parameter value.
webFrame.setZoomLevel(level)
level
Number - Zoom horizontally
Modify the scale level to the specified horizontal value. The original size is 0, and each growth means zooming in by 20% or 20%, with the default limit between 300% and 50% of the original size.
webFrame.getZoomLevel()
Returns the current zoom horizontal value.
webFrame.setZoomLevelLimits(minimumLevel, maximumLevel)
minimumLevel
Number
maximumLevel
Number
Sets the maximum and minimum values for the zoom level.
webFrame.setSpellCheckProvider(language, autoCorrectWord, provider)
language
String
autoCorrectWord
Boolean
provider
Object
Set up a spell check provider for the input box or text field .
provider
must be an
object that has a
spellCheck
whether the swept word is spelled correctly .
Example, using node-spellchecker as a provider:
webFrame.setSpellCheckProvider("en-US", true, {
spellCheck: function(text) {
return !(require('spellchecker').isMisspelled(text));
}
});
webFrame.registerURLSchemeAsSecure(scheme)
scheme
String
Register
scheme
for a secure scheme.
Secure schemes do not trigger mixed
content
warnings. For example,
https
data
are secure schemes because they cannot be invalidated by active cyberattacks.
webFrame.registerURLSchemeAsBypassingCSP(scheme)
scheme
String
Ignore the security policy of
the current page content and load directly
scheme
webFrame.registerURLSchemeAsPrivileged(scheme)
scheme
String
Register scheme as a
secure scheme through the
scheme
policy of the resource, allowing the registration of serviceWorker and support for fetch APIs.
webFrame.insertText(text)
text
String
Insert content into the primary color that gets the focus .
webFrame.executeJavaScript(code[, userGesture])
code
String
userGesture
Boolean (optional)
- false by
false
.
Evaluation page code .
In the browser window, some HTML
APIs, such as
requestFullScreen
can only be used by user gestures.
Setting
userGesture
true
this limit .