gem_finder_1991
gem_finder_1991

Reputation: 27

How do I make an image in PDF open its link in new pop-up window?

I am embedding a PDF in an HTML. There are some images with links in PDF. I want to make those link open in a pop-up window/ new window rather than a new/ the same tab on click.

Upvotes: 1

Views: 184

Answers (3)

mehtasuraj09
mehtasuraj09

Reputation: 139

You provide a link on PDF in such a way that the link which is to be opened in pop-up should be a parameter. Write a jquery/js script to access that param and open a pop-up window or boostrap modal to show the link in it. I hope this helps.

Upvotes: 1

webbist
webbist

Reputation: 456

You could do this in JS/jQuery if non of the target attributes work for you

   return function(el) {
        el.find('a').on('click', function(e) {
          e.preventDefault();
          var i = $(this).attr('class');
          var u = this.href;
          var c = {h:370, w:550};
          var xPos = ($(window).width()-c.w)/2;
          var n = window.open(u,i,'height='+c.h+',width='+c.w+',left='+xPos+',top=60,screenX='+xPos+',screenY=60');
          if (window.focus) { n.focus(); }
        });
    };

Upvotes: 2

SURU
SURU

Reputation: 188

According to the HTML5 Spec:

A valid browsing context name is any string with at least one character that does not start with a U+005F LOW LINE character. (Names starting with an underscore are reserved for special keywords.)

A valid browsing context name or keyword is any string that is either a valid browsing context name or that is an ASCII case-insensitive match for one of: _blank, _self, _parent, or _top." - Source

So using

target="_blank"

Should help you.

Upvotes: 1

Related Questions