Chumtarou
Chumtarou

Reputation: 313

Jquery Cycle - go to new URL at the end of cycle

Is there a way to make the last slide's next arrow link to a new page?

I've been trying to use this code as a starting point http://jquery.malsup.com/cycle/end.html but I don't seem to be getting anywhere when combined with captions.

Edit: unlike this example, I would like to have the End function work without the timed scrolling. Ie timeout: 0 so that you have to manually advance each slide. Upon the last slide it goes to a new URL. Example: http://jsfiddle.net/YFyKg/5/

Thanks in advance for your help!

Upvotes: 0

Views: 765

Answers (2)

jValdron
jValdron

Reputation: 3418

Here is your answer:

$(document).ready(function() {
$('#slideshow').cycle({
    fx: 'scrollHorz',
    nowrap: false,
    timeout: 0,
    fx: 'scrollHorz',
    next: '.next',
    prev: '.prev',
    after: onAfter,
    onPrevNextEvent: function(isNext, zeroBasedSlideIndex) { 
        if(isNext && zeroBasedSlideIndex == 0)
        {
        document.location = 'http://www.google.ca';   
        }
    }
});
function onAfter(curr, next, opts) {
var caption = (opts.currSlide + 1) + ' / ' + opts.slideCount;
$('#caption').html(caption); }
});

Upvotes: 4

Evan Levesque
Evan Levesque

Reputation: 3213

$('#slideshow').cycle({ 
    fx:      'scrollHorz', 
    timeout:  2000, 
    autostop: 1, 
    end:      function() {  
        window.location="next_page.php";
    } 
});

Upvotes: 0

Related Questions