hash values for Cycle plugin with multiple slideshows on one page
in Using jQuery Plugins
•
11 years ago
I'm a javascript rookie trying to figure out a way to get bookmarkable URLS for the images on a single page with multiple slideshows. I must admit I don't really understand the first part of the code on the Cycle demo page for this, which only works for a page with one slideshow:
$(function() { | |
var index = 0, hash = window.location.hash; | |
if (hash) { | |
index = /\d+/.exec(hash)[0]; | |
index = (parseInt(index) || 1) - 1; // slides are zero-based | |
} | |
$('#slideshow').cycle({ | |
fx: 'shuffle', | |
speed: 'fast', | |
startingSlide: index, | |
timeout: 3000, | |
after: function(curr,next,opts) { | |
window.location.hash = opts.currSlide + 1; | |
} | |
}); | |
}); |
While I'm shopping for a little guidance, it would also be really cool if the hash tags were semantic somehow with respect to each slideshow e.g.:
www.mysite.com/slideshow5.html#beach1
www.mysite.com/slideshow5.html#beach2
www.mysite.com/slideshow5.html#penguins5
etc.
Serious kudos to anyone who can help. Thanks in advance for looking.
1