How to view PDF in pop-up when clicking link using html/css only?

Asked

Viewed 719 times

1

On a given page of a website, I have an image with a link pointing to a PDF file. As it currently stands, when the user clicks on the image, the PDF file opens in another browser tab.

But I need to find a way to, when the user clicks on the image, the PDF will be displayed in a pop-up on the current page, preferably using only html/css. The code is currently like this:

<a href="images/CartaServicos/Assinatura-Externa.pdf" target="_blank"> 
    <img src="images/CartaServicos/AssinaturaExterna.PNG" alt="AssinaturaExterna"/>
</a>

If you could shed some light, I’d appreciate it.

1 answer

1

Leandro, I believe the only solution is with Javascript. The link will open in a new window, and with Javascript you can set the size of this new window, thus generating a "pop-up".

<a href="http://seulinkaqui.com" 
  target="popup" 
  onclick="window.open('http://seulinkaqui.com','popup','width=600,height=600'); return false;">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.