Ask coding questions

← Back to all posts
how to create a window in which it would be possible to write text and save it
Agzamikail (2)

how to create a window in which it would be possible to write text and save it, as well as display all the below, saved on html
HELP

Comments
hotnewtop
xxpertHacker (855)

Use globalThis.open, and then write into the window via basic DOM Manipulation, and when you've finished writing to it, you could save it via this snippet:

function saveDocument(document, fileName = "download.html") {
    const doctype = String(document.doctype);

    const contents = String(document.documentElement.outerHTML);

    const str = `${doctype}\n${contents}`;

    const file = new File(
        [str],
        fileName, {
            type: "text/html",
            ending: "native"
        }
    );

    const blobURL = URL.createObjectURL(file);

    const anchor = document.createElement("a");

    anchor.setAttribute("href", url);
    anchor.setAttribute("download", fileName);

    anchor.click();
}
RYANTADIPARTHI (6000)

that's not possible with just html. You need js. But i don't think windows are possible either.

Agzamikail (2)

no could be done So that there was not a window but on the site the line in which the text was written and it was saved and from the bottom showed all the saved text, and the saved text could be deleted using the code @RYANTADIPARTHI