i was trying to create a download button which on clicking takes the text from a particular website/link takes all the text from there and download it on the users system in .txt format. here's what i've been trying and not working out code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
<title>You Tube Video Summarizer</title>
</head>
<body>
<div id="container">
<img id="img" src="img.jpeg">
<h2>YouTube Video Summarizer</h2>
<div class="video">
<label>Enter your url here</label>
<br>
<input type="url" id="url" placeholder="https://www.youtube.com/results?search_query=youtube">
</div>
<br>
<div class="mb-3">
<label for="exampleFormControlInput1" class="form-label" >Choose summarization algorithm</label>
<br>
</div>
<select class="form-select" aria-label="Default select example">
<option selected>Default</option>
<option value="1">NLTK</option>
<option value="2">spaCy</option>
</select>
<br>
<br>
<label for="customRange1" class="form-label">Select length of summary</label>
<br>
<input type="range" class="form-range" id="customRange1">
<br>
<br>
<button type="button" class="btn btn-primary" id="summarize">Summarize</button>
<br>
<br>
<button type="button" id = "download" class="btn btn-primary">Download</button>
</div>
<script>
function alert(){
var save = document.getElementById("download");
var dl = document.createElement('a');
dl.setAttribute('href', 'link(https//...', 'data:text;charset=utf-8,' + encoderURIComponent(save));
dl.setAttribute('download', 'filename.txt');
dl.click();
}
document.addEventListener('DOMContentLoaded', function(){
document.getElementById('alertButton').addEventListener('click', alert);
});
</script>
</body>
</html>