Sample code snippet:
index.ejs
<p><a href="<%=link%>" class="btn btn-primary" role="button">Download</a></p>
app.js
var express = require('express'); var router = express.Router();
router.get('/', function(req, res, next) {
res.render('index', {link:'http://download1588.mediafireuserdownload.com/**c5cq****rb2a/***.jpg'});
});
how to get this link as href tag value so that i can download from this link.
getElementById('someDiv'); // create <a> tag var tag = document. createElement(a); // set the href attribute tag. setAttribute('href', exampleHref); // append the node to the parent div. appendChild(tag);
If you want to render a static page then go for an HTML file and if you want to render a dynamic page where your data coming from various sources then you must choose an EJS file. Good for the static web page.
Here is the way you would do that with ejs:
<p><a href="<%= link %>" class="btn btn-primary" role="button">Download</a></p>
res.render('index.ejs', { link: "<your link here>" });
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With