electron/spec/fixtures/pages/webview-custom-zoom-level.html
2017-02-18 01:41:39 +05:30

26 lines
793 B
HTML

<html>
<body>
<webview nodeintegration src="zoom://host1" id="view" partition="webview-temp"/>
</body>
<script>
const {ipcRenderer, webFrame} = require('electron')
const view = document.getElementById('view')
let finalNavigation = false
view.addEventListener('dom-ready', () => {
if (!finalNavigation && !view.canGoBack()) {
view.setZoomLevel(2.0)
}
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) {
finalNavigation = true
view.goBack()
}
})
})
})
</script>
</html>