Update 'frontend.js'
This commit is contained in:
parent
3d7c53388d
commit
21e14f2c0c
1 changed files with 15 additions and 5 deletions
20
frontend.js
20
frontend.js
|
@ -109,11 +109,21 @@ function createParagraph(elementID, text) {
|
||||||
return elem
|
return elem
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBody() {
|
function initBody(bodyID) {
|
||||||
const element = document.createElement("body");
|
// Create a new body element with the desired id
|
||||||
element.id = "body";
|
const newBody = document.createElement("body");
|
||||||
document.appendChild(element);
|
newBody.id = bodyID;
|
||||||
return element;
|
|
||||||
|
// Get a reference to the existing body element (if any)
|
||||||
|
const oldBody = document.body;
|
||||||
|
|
||||||
|
// Replace the existing body (if present) with the new one
|
||||||
|
if (oldBody) {
|
||||||
|
document.documentElement.replaceChild(newBody, oldBody);
|
||||||
|
} else {
|
||||||
|
// Simply append the new body if none exists
|
||||||
|
document.documentElement.appendChild(newBody);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createButton(elementID, text, attributes = {}) {
|
function createButton(elementID, text, attributes = {}) {
|
||||||
|
|
Loading…
Reference in a new issue