The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Disable link, fire modal problem

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #38173

    Hi, everyone,

    Here’s my problem. I’ve been scratching my head around this one for a while now so hopefully someone has some insight.

    On a page I have a number of links to PDF files. What I need to do is…

    1. User clicks any link to a PDF

    2. Instead of the PDF opening, it triggers a modal box

    3. Once the user closes the modal, the PDF on the link they clicked then opens

    I know this seems odd but this is what the client wants. Basically they don’t want people to be able to download PDFs without seeing the modal box (the intention being to have them fill out a form or opt out).

    Things to know:

    1. This is on WordPress

    2. I’m using Fancybox for the modal

    3. The page with the PDF links is a public page and there’s no intention to instead have users fill a form to have access to the page itself

    4. I will be employing a cookie method so they just need to click a PDF once to see the modal, after that they don’t see the modal again if they’ve closed it.

    Any input would be very much appreciated!




    If you have a class on the link I’m sure you could do something with JS.

    Grab the URL on click, open the modal box, when the modal box gets closed, send the user to the URL.

    $('.classname').click(function() {
    var url = $(this).attr('href');

    // etc.

    Arrgh, thanks! This is a good example of missing the simple approach with a complex concept.

    Cheers ;)

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.