Answered PDF in new Window? jQuery

  • Friday, July 06, 2012 4:01 PM
     
      Has Code

    I have found MULTIPLE entries on this and other sites about using jQuery to open PDFs in a new window. All of them require me to add a CEWP to a page and manipulate page by page. We need every document library in our entire site to do this and we cannot edit absolutely every library page.

    So the answer, we thought, was obvious: Add to master.  We have added the following and while it does indeed open the PDF in a new window, it also still opens the same PDF in the same window.

    $(document).ready(
        function () {
            //Need to open all PDF files in a new window
            $('a[href*=".pdf"]').click(function () {
                window.open(this.href);
                return false;
            });
        }
    );

    What are we missing?


    - Thank you. Respectfully, Janette M. Ricker

All Replies