I know this might be dumb, but this code won’t display when reloaded:
function addApp() {
// Get user input for the variables
const title = prompt("Enter the title:");
const src = prompt("Enter the source:");
const img = prompt("Enter the image URL:");
const name = prompt("Enter the name:");
// Create a new button element
const button = document.createElement('button');
// Create a new anchor element and set its attributes
const anchor = document.createElement('a');
anchor.className = 'app';
anchor.onclick = function() {
openWindow(title, src);
};
// Create a new image element and set its source attribute
const image = document.createElement('img');
image.src = img;
// Create a new paragraph element and set its text content
const paragraph = document.createElement('p');
paragraph.className = 'namething';
paragraph.textContent = name;
// Append the image and paragraph elements to the anchor element
anchor.appendChild(image);
anchor.appendChild(paragraph);
// Append the anchor element to the button element
button.appendChild(anchor);
// Append the button element to the document body
document.body.appendChild(button);
// Save the resulting HTML to localStorage
localStorage.setItem('savedHTML', document.body.innerHTML);
// Retrieve the saved HTML from localStorage
const savedHTML = localStorage.getItem('savedHTML');
// If there is saved HTML, display it on the page
if (savedHTML) {
document.body.innerHTML += savedHTML;
}
}