Lead Squared by default does not provide the functionality to download a file when a button is clicked and it make it mandatory to submit some form. So this slides contain the twik we used to enable file download on click of link
2. Adding functionality of file download on
link click
Problem:LeadSquared does not have the option to download a file, without
any form being submitted
Solution: we have used different techniques for different browsers
Background: Page A should contain a button/link on click of which a pdf should
be downloaded. This is not possible by front-end twik. It is server side setting in
php.
Lead Squared was offering pdf download functionality, but a form needs to be
submitted and then download link is shown. But we did not want to fill any
form
So we created the form F on page A along with download link D.
Published page A
3. Adding functionality of file download on
link click
When page A is browsed it showed the form. We submitted the details in the
form. A popup was opened with download link.
We copied this download link L and then edited the page A to make form
invisible.
So on click of button D next time we use this copied L as described below.
4. Adding functionality of file download on
link click
Chrome solution: on click of download button we are opening that url in new
chrome tab using
window.open("https://web.mxradon.com/l/DownloadFile.aspx?oid=6533&&ei
d=29b9228d-4968-11e5-981b-22000a9700b4&&etype=lp","_blank");
This solution did not work in Internet explorer. i.e. in chrome previous js line
was downloading a pdf.
But in Internet explorer it was giving some error
Internet explorer solution:
The button which comes on popup we copied that button element from there
and kept it below our download button and when our download button is
clicked, we click this button element using javascript. I do not know the
reason why this technique is working in IE. May be related to the way browser
is created.
5. Adding functionality of file download on
link click
Safari solution: Safari does not provide us the feature to download a pdf file
on click of link. In safari we can open the pdf in new window, but not
download directly. After pdf is opened in new tab. We have to explicitly save
it.
So that way it was very simple, because pdf is hosted by leadsquared so we
just open that link in new tab using window.open(“leadsquared pdf link”);