Advertisement
Baru_Berbagi

script.js

Oct 25th, 2022
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const textarea = document.querySelector("textarea"),
  2. fileNameInput = document.querySelector(".file-name input"),
  3. selectMenu = document.querySelector(".save-as select"),
  4. saveBtn = document.querySelector(".save-btn");
  5.  
  6. selectMenu.addEventListener("change", () => {
  7.      let selectedOption = selectMenu.option[selectMenu.selectedIndex].text;
  8.      
  9. });
  10.  
  11. saveBtn.addEventListener("click", () => {
  12.     const blob = new Blob([textarea.value], {type: selectMenu.value});
  13.     //
  14.     const fileUrl = URL.createObjectURL(blob);
  15.     const link = document.createElement("a");
  16.     link.download = fileNameInput.value;
  17.     link.href = fileUrl;
  18.     link.click();
  19. });
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement