-1

I have tried many things to get this to work, I am basically trying to have the lightbox photo show up(which it does), and when clicked on, opens up a new tab with a specified URL. The image that I am trying to have link to a url in new tab is "images/ad1.jpg", which is in the code. Please show me the proper code and way it needs to be inputted so I can do this. I greatly appreciate everyones support on this and the great community of stackoverflow. Thank you.

(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);
Kitsune
  • 19
  • 3

2 Answers2

1

You should modify jquery.prettyPhoto.js

$pp_pic_holder.find('.pp_previous, .pp_arrow_previous').bind('click',function(){
    $.prettyPhoto.changePage('previous');
    return false;
});

$pp_pic_holder.find('.pp_next, .pp_arrow_next').bind('click',function(){
   $.prettyPhoto.changePage('next');
   return false;
});                               

To

$pp_pic_holder.find('.pp_arrow_previous').bind('click',function(){
   $.prettyPhoto.changePage('previous');
   return false;
});

$pp_pic_holder.find('.pp_arrow_next').bind('click',function(){
    $.prettyPhoto.changePage('next');
    return false;
});

$(document.body).on("click", "#fullResImage", function(){
    window.open($(this).attr("src"));
})

I hope it will work.

Wheeler
  • 296
  • 1
  • 4
  • 12
1

This library has an option of image_markup, documentation, using that will avoid javascript solutions.

Add a link with target="_blank" within the image_markup option when you instance prettyPhoto

image_markup: '<a href="{path}" target="_blank"><img id="fullResImage" src="{path}" /></a>'

Example

$("a[rel^='prettyPhoto']").prettyPhoto({image_markup: '<a href="{path}" target="_blank"><img id="fullResImage" src="{path}" /></a>'});

Otherwise, you'd have to do something like this, jsFiddle Example

$(document.body).on('click', '#fullResImage', function(){
    window.open(this.src, '_blank');
});
Brian Dillingham
  • 9,118
  • 3
  • 28
  • 47