I am writing code for where user clicks on an export link then an excel sheet will be downloaded. As of now working fine but It is getting downloaded directly after user clicks on that link but Here what I want is If user clicks on 'export' link then a prompt box should show if user clicks on ok then only that excel file has to be downloaded. I know this is possible through JavaScript only but I exactly dont know how to achieve it. hope somebody helps. Thanks.
my code is :
<ul class="nav child_menu">
<li><a href="page1.php"><i class="fa fa-info-circle"></i>menu-1</a></li>
<li><a href="page2.php"><i class="fa fa-building-o" aria-hidden="true"></i>menu-2</a></li>
<li><a href="page3.php"><i class="fa fa-caret-square-o-up" aria-hidden="true"></i>menu-3</a></li>
<li><a href="page4.php"><i class="fa fa-steam-square" aria-hidden="true"></i>menu-4</a></li>
<li><a href="export.php" title="Export to the Excel sheet"><i class="fa fa-steam-square" aria-hidden="true"></i>Export</a></li>
<li><a href="export.php" title="Export to the Excel sheet" onclick="return confirm()"><i class="fa fa-steam-square" aria-hidden="true"></i>Export</a></li>
function confirm()
{
if (confirm('Do you want to download?')) {
return true;
}
}