Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const textarea = document.querySelector("textarea"),
- fileNameInput = document.querySelector(".file-name input"),
- selectMenu = document.querySelector(".save-as select"),
- saveBtn = document.querySelector(".save-btn");
- selectMenu.addEventListener("change", () => {
- let selectedOption = selectMenu.option[selectMenu.selectedIndex].text;
- });
- saveBtn.addEventListener("click", () => {
- const blob = new Blob([textarea.value], {type: selectMenu.value});
- //
- const fileUrl = URL.createObjectURL(blob);
- const link = document.createElement("a");
- link.download = fileNameInput.value;
- link.href = fileUrl;
- link.click();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement