-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrenderer.js
30 lines (22 loc) · 920 Bytes
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function moveWebview(existingWebview, container) {
const webview = document.createElement('webview');
const { attributes } = existingWebview;
const originalGuestInstance = existingWebview.guestinstance;
console.log('original guestinstance', existingWebview.guestinstance);
for (let i = 0; i < attributes.length; i += 1) {
webview.setAttribute(attributes[i].nodeName, attributes[i].nodeValue);
}
console.log('copied guestinstance', webview.guestinstance);
container.appendChild(webview);
existingWebview.parentNode.removeChild(existingWebview);
return webview;
}
window.addEventListener("load", () => {
const button = document.getElementById("button");
const webviews = document.getElementById("webviews");
let index = 0;
button.addEventListener("click", () => {
index = (index + 1) % 2;
moveWebview(document.getElementById("webview"), webviews.children[index]);
});
});