feat: replace BrowserView with WebContentsView (#35658)
This commit is contained in:
parent
a94fb2cb5d
commit
15c6014324
76 changed files with 2987 additions and 1531 deletions
|
@ -1,32 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<style>
|
||||
.webview {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<button class="close-btn">close webview</button>
|
||||
<webview class="webview" src="./webview.html"></webview>
|
||||
<script>
|
||||
const close = document.querySelector('.close-btn')
|
||||
const webview = document.querySelector('.webview')
|
||||
|
||||
webview.addEventListener('close', () => {
|
||||
webview.parentNode.removeChild(webview)
|
||||
})
|
||||
|
||||
close.addEventListener('click', () => {
|
||||
webview.executeJavaScript('window.close()', true)
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<button id="closeBtn">close webview</button>
|
||||
<webview id="webview" src="webview.html"></webview>
|
||||
<script>
|
||||
webview.onclose = () => webview.remove()
|
||||
closeBtn.onclick = () => webview.executeJavaScript('window.close()', true)
|
||||
</script>
|
||||
|
|
|
@ -19,7 +19,7 @@ app.whenReady().then(() => {
|
|||
});
|
||||
|
||||
contents.on('did-finish-load', () => {
|
||||
win.webContents.executeJavaScript('document.querySelector(\'.close-btn\').click()');
|
||||
win.webContents.executeJavaScript('closeBtn.click()');
|
||||
});
|
||||
|
||||
contents.on('will-prevent-unload', event => {
|
||||
|
|
|
@ -1,19 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>webview page</h1>
|
||||
<script>
|
||||
window.addEventListener('beforeunload', event => {
|
||||
event.returnValue = 'test'
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<h1>webview page</h1>
|
||||
<script>
|
||||
window.addEventListener('beforeunload', event => {
|
||||
event.returnValue = 'test'
|
||||
})
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue