electron/spec/fixtures/pages/webview-custom-zoom-level.html

27 lines
793 B
HTML
Raw Normal View History

2017-02-17 15:48:30 +00:00
<html>
<body>
<webview nodeintegration src="zoom://host1" id="view" partition="webview-temp"/>
2017-02-17 15:48:30 +00:00
</body>
<script>
const {ipcRenderer, webFrame} = require('electron')
const view = document.getElementById('view')
let finalNavigation = false
view.addEventListener('dom-ready', () => {
if (!finalNavigation && !view.canGoBack()) {
2017-02-17 15:48:30 +00:00
view.setZoomLevel(2.0)
}
2017-02-17 15:48:30 +00:00
view.getZoomLevel((zoomLevel) => {
view.getZoomFactor((zoomFactor) => {
ipcRenderer.send('webview-zoom-level', zoomLevel, zoomFactor, view.canGoBack(), finalNavigation)
if (!view.canGoBack() && !finalNavigation) {
view.src = 'zoom://host2'
} else if (!finalNavigation) {
2017-02-17 15:48:30 +00:00
finalNavigation = true
view.goBack()
2017-02-17 15:48:30 +00:00
}
})
})
})
</script>
</html>