I am writing a javascript function to open a link to download a pdf. (The function will check for a string, if the condition satisfies it will open a link, if the condtion doesnot satisfy it will open another link).
<tr>
<td align="center">
<a href="#" onclick="openPdfReport()" style="text-decoration: none"><font size="2" color="RED"><b><u>View Report </u></b></font></a>
</td>
</tr>
function openPdfReport()
{
var nameOnly = "";
//This value s is only for testing puropse
var s = "/testdata/e-Form/app/Eforms/Certificates/1234/abcdcertificate12345.pdf";
var totalLength = s.length();
if(totalLength>60)
{
nameOnly=s.substring(45, 60);
String ackNoOnly = s.substring(60, s.indexOf("."));
if(nameOnly.equalsIgnoreCase("abcdcertificate"))
{
window.open("http://www.abc.com/abc.pdf",'_blank');
}
else
{
window.open("http://www.abc.com/abc.xls",'_blank');
}
}
else
{
window.open("http://www.abc.com/abc.xls",'_blank');
}
}
But when I click on the View Report link, the report is not downloading. Not able to find where i am missing. Any help is highly appreciated.
Thanks and Regards