0

I need some assistance with this. I am trying to make an image (ad1.jpg) link url to be opened in a new tab. How would I do this? I have tried many options to make this work. I might be placing the code wrong but I have tried window.open, and many more options. Any help is greatly appreciated. Thanks

(function($){
    $(window).load(function(){
        if(jQuery.isFunction(jQuery.fn.prettyPhoto)) {
            $.prettyPhoto.open(
                "images/ad1.jpg", // Image to be opened
                "title",    // Title of the pop-up
                "desc."     // The description
            );
            setTimeout(function() {
                $.prettyPhoto.close();
            }, 10000); // autoclose after 10 seconds
        } else {
            console.log("PrettyPhoto is not defined."); // log this message
        }
    });
})(jQuery);
Jeff B
  • 29,943
  • 7
  • 61
  • 90
Kitsune
  • 19
  • 3

2 Answers2

0

Is jquery a prerequisite? Because if you want to click on an image and open it in a new tab you can just use target="_blank" like this:

<a href="http://link.to.your.image" target="_blank">
<img src="http://link.to.your.image" />
</a>

See this jsfiddle demo

tgogos
  • 23,218
  • 20
  • 96
  • 128
0

If you want the picture to be opened in a new tab, a simple link <a href="images/ad1.jpg" target="_blank"> on your picture should do the work.

But if you want to open the picture in a new tab, with the borders etc... from pretty photo, I think you'll have to create a page dedicated to that, and create a link to it.

tetram
  • 195
  • 1
  • 8
  • This would not work. The image is defined please look at the HTML does no good in there. – Kitsune Aug 27 '14 at 19:10
  • I'm a little lost. Could you describe more specificaly what you want to do ? – tetram Aug 27 '14 at 19:12
  • yes, in the script, where the code "images/ad1.jpg" I need for when the image is clicked it opens a url in a new tab. This script has no html it sits in the footer and when the site loads the pop up works just need the image when clicked to open a new tab with a specific url – Kitsune Aug 27 '14 at 19:17
  • When the pop-up is shown, I guess you could add a onclick event to it ? Using jquery click function. – tetram Aug 27 '14 at 19:48