Skip to main content

How do I prevent a link on an overlay page from opening in another overlay page in Drupal 7?

I have created a custom module that opens up a page in the admin overlay. Upon going to that page, a PDF is generated and the link to the file is displayed on the page. I created the link using l(), and gave the link a target attribute of '_blank' to open in a new tab/window.

l('Click here to download your PDF file.', $f_url, array('attributes' => array('target' => '_blank')))

The link looks like it is generated correctly.

<a href="http://xxxx.com/sites/default/files/custom-pdf/xxxx_4.pdf" target="_blank">Click here to download your PDF file.</a>

When I click on it, it opens in a new window, but somehow the overlay fragment is tacked onto the end of the URL in the new window address bar, which appears as the following: http://xxxx.com/sites/default/files/custom-pdf/xxxx_4.pdf#overlay-context=test.html.

The browser throws up a dialog box with a title of "Adobe PDF Document" and a message alert of "This operation is not allowed".

If I click this link from a non overlay page, it does exactly what it's supposed to do: Open the PDF in a new window.

I'm not exactly sure what's going on here.

How is the overlay fragment being appended to the URL, and how can I prevent it?

demarts
  • 67
  • 1
  • 8