How to call disclaimer page on all media files in Drupal? I want to display a terms n condition page on every media of website. I collect all media from file managed table of database. I also convert fid to url. Now for each media url I need a disclaimer page. 

My issue is something related to this link.

For example: 

When I click on each report of news table shown below, on clicking of (say) linux-minimal.pdf , it first redirect to some node which is my disclaimer url, and then pdf open. 

How can I achieve this?

I have tried some code which is actually not working. It is:

function hook_init(){
    $get_current_path_media = $GLOBALS['base_url'].'/'.current_path();
    if($get_current_path_media == 'http://my-website/sites/default/files/569338.pdf'){
        drupal_goto('disclaimer');
    }
}
Here is an example

&lt;a class="test" href="https://bitcoin.org/bitcoin.pdf"&gt;bitcoin.pdf&lt;/a&gt;

&lt;script&gt;
    $('.test').click(function() {
    alert('Your disclamer goes here');
});
&lt;/script&gt;


SEE A DEMO HERE

In Drupal to use jQuery you need to wrap it in 

(function ($) {

    //code goes here

})(jQuery);


so your code should look like this

(function ($) {
  $( document ).ready(function() { 
    $('.test').click(function() {
        alert('your disclamer goes here');
    });
  });
})(jQuery);


PS: If your div class is outside the &lt;a&gt;

&lt;div class="test"&gt;&lt;a href="https://bitcoin.org/bitcoin.pdf"&gt;bitcoin.pdf&lt;/a&gt;&lt;/div&gt;


then use it like this

&lt;script&gt;
(function ($) {
  $( document ).ready(function() { 
    $('.test a').click(function() {
        alert('your disclamer goes here');
    });
  });
})(jQuery);
&lt;/script&gt;