Is there any way to link directly to the second or third slide in a slide show?
You can add a url parameter and handle it.
Something like:
https://my-doamin.com/slideshow?s=1
(Note: the slide index starts from zero, so index 1 is the second slide)
Then on the slideshow page code:
import wixLocation from 'wix-location';
const startIndexParam = wixLocation.query?.s;
let startIndex = 0;
$w.onReady(() => {
if(!isNaN(startIndexParam)){
startIndex = Number(startIndexParam);
if(!Number.isInteger(startIndex) || startIndex < 0 || startIndex > $w('slideShow').slides.length - 1){
startIndex = 0;
}
}
$w('slideShow').changeSlide(startIndex);
})
Thanks, I’ll give that a try.
How does this work if I need one link to go to the first page of the slide show and second link to go to the second and a third to go to the third page?
First slide:
[u]https://my-doamin.com/slideshow?s=0[/u]
Second slide
[u]https://my-doamin.com/slideshow?s=1[/u]
Third slide:
[u]https://my-doamin.com/slideshow?s=2[/u]
Forth slide:
[u]https://my-doamin.com/slideshow?s=3[/u]
Just a small fix to the code I posted - to convert the param into a number. see my post.
Hi J. D. Thanks for the code. copied it into my code but I’m getting several errors that I don’t know how to resolve. Can you tell me what I’m doing wrong?
Hi, first of all:
replace the startIndex.slides.length by $w(‘slideShow’).slides.length
Second, replace the changeSlide(startIndex) by $w(‘slideShow’).changeSlide(startIndex)
Third- remove the extra { after the $w(‘slideShow’).changeSlide(startIndex)
That seems to fix all the errors. Here is how it looks now.
It doesn’t seem to be working. Maybe I am doing the link wrong. Here is what I have for the link.
https://jonpardew.wixsite.com/website-6/copy-of-doorstairs/slideshow?s=2
You forgot to publish the website after implementing the fix.
Okay, It works now thanks for all your help. I’m sorry that I don’t know more about this. You’ve been very kind.