Let's try the querystring approach.
On the page with the stellar, you will add this function somewhere inside a script
tag but outside the jQuery's $(document).ready()
(Script from here):
function getParameterByName(name){
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
And on your $(document).ready()
this script (better if after everything, specially stellar):
var slideToGo = getParameterByName('slide');
slideToGo = parseInt(slideToGo); //try make it a number
if($.type(slideToGo) == 'number'){ //make sure is a number
var delay = setTimeout(function(){
$('#navigation ul').find('li[data-slide='+slideToGo+'] .item a').click();
},500);
}
So every time your page with parallax is accessed, this script will look for the ?slide=
in the URL's querystring. If finds it (and is a string and non empty), will try find the LI which has the data-slide
equal to the number in the ?slide=
and click on it's anchor.
I think this may work. I added a little setTimeout to give some time for stellar to render. I couldn't find in its doc if it had a onComplete
event or something like. Would be alot better but since seems don't have, let's try this way.
And of course, on the static page, the link would be pagewithstellar.html?slide=NN
where NN is the number of the data-slide you want to go back to.
Update:
If you really want to use hash (for example: parallaxpage.html#slide-4), you'll need the following (swap the above codes with those below, then):
function getSlideNumberInHash() {
var hash = document.URL.substr(document.URL.indexOf('#')); //returns #slide-N
var slideNumber = hash.substr(hash.indexOf('-')+1); //returns -N. The +1 will make it return N
return slideNumber;
}
var slideToGo = getSlideNumberInHash();
slideToGo = parseInt(slideToGo); //try make it a number
if($.type(slideToGo) == 'number'){ //make sure is a number
var delay = setTimeout(function(){
$('#navigation ul').find('li[data-slide='+slideToGo+'] .item a').click();
},500);
}
I used document.URL.substr
instead of window.location.hash
because of this comment. We not working with iframes but better prevent if needed someday :P)