How can I open a pdf file in a new window or download a pdf file on button click?

How can I open a pdf file in a new window or download a pdf file on button click?

JNeed86JNeed86 Posts: 1Questions: 1Answers: 0

Everything works fine until it gets to the "window.open(pdf, '_blank'); line. Then it will auto refresh the page and does not open the pdf file. Can someone tell me what I am doing wrong here? All I want it do is open the PDF file OR download it, does not matter which one. Be gentle, I am new to Jquery, HTML, and ASP.net.

   $(document).ready(function () {
                var table = $('#table_id').DataTable(
                    {
                        dom: 'Blfrtip',
                        searching: true,
                        select: true,
                        buttons: ['copy', 'excel', 'csv', 'pdf'],
                        "columnDefs": [{
                        "targets": -3,
                        "data": null,
                        "defaultContent": "<button>Open</button>"
                    }]
                    });


                $('#table_id tbody').on('click', 'button', function () {
                    var data = table.row($(this).parents('tr')).data();
                    var pdf = "D:\\TMT\\TCS\\HubData\\BOL\\" + data[3] +".pdf";
                    alert(data[3] + "s location is: " + pdf);
                    window.open(pdf, '_blank');

                });
      });

Answers

This discussion has been closed.