I am working in a simple webpage that requires to download the result as image file in the last step.
I have created a hidden HTML button for downloading result image and set its display to None by CSS. Now I have changed it's visibility from None
to block
using a simple JavaScript program.
My program looks something like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<style>
#down_button
{
display: none;
}
</style>
</head>
<body>
<h1>Press the button to start downloading</h1>
<input type="button" id="down_button" value="Download noww !" >
<script src="testing.js"></script>
</body>
</html>
and my JS file looks like this:
const btn = document.getElementById('down_button');
down_button.style.display='block'; //displays the button
Is it possible to bind a URL with the button such that whenever a user press the button; the downloading will start in to the browser
Please explain with vanilla JS.