Hey guys I have a one page site (that acts as 4 pages), and I needed to get all 4 pages on their own unique URL.
To do this I hired someone who had experience with this and he duplicated my one page site 3 more times, making 4 different pages. Wrote custom code so the URL’s would be different and so the click through animation would take them to the correct page.
Making all of this so the user is unaware.
It works great on desktops as you can see if you click this live link:
http://travisbklein.webflow.io/
Designer link (each page has its own page code that you can view):
https://preview.webflow.com/preview/travisbklein?preview=c9a223b9ad616b860ba1acc25a62ff34
Problem is, it doesn’t work on mobile devices, and I’m hoping it might be a simple fix. If not I’m going to have to hire someone who can help me. (not sure if original person is still available)
So yea, thanks for any help!
<script type="text/javascript">
var Webflow = Webflow || [];
Webflow.push(function () {
// The Grind
$(".navelement").click(function(){
//When a nave element is clicked
//Remove all current nav classes
$(".navelement").removeClass("current");
//Then add current to the one you just clicked
$(this).addClass("current");
//Update URLs
var scrollV, scrollH, loc = window.location.hostname;
var currentSlideURLname = $('.navelement.current').html();
var currentSlideURLlowercase = currentSlideURLname.replace(/\s+/g, '-').toLowerCase();
// if ("pushState" in history)
if (("pushState" in history) && (currentSlideURLlowercase !== "home"))
history.pushState("", currentSlideURLname, currentSlideURLlowercase);
else if (("pushState" in history) && (currentSlideURLlowercase === "home"))
history.pushState("null", "null", "/");
else {
// Prevent scrolling by storing the page's current scroll offset
scrollV = document.body.scrollTop;
scrollH = document.body.scrollLeft;
loc.hash = "currentSlideURLlowercase";
// Restore the scroll offset, should be flicker free
document.body.scrollTop = scrollV;
document.body.scrollLeft = scrollH;
}
});
});
</script>
this is another pages code just for reference on the thread for easy readability:
<script type="text/javascript">
var Webflow = Webflow || [];
Webflow.push(function () {
$("a[data-ix='clk-myjourney']").click();
$(".navelement").click(function(){
//When a nave element is clicked
//Remove all current nav classes
$(".navelement").removeClass("current");
//Then add current to the one you just clicked
$(this).addClass("current");
//Update URLs
var scrollV, scrollH, loc = window.location.hostname;
var currentSlideURLname = $('.navelement.current').html();
var currentSlideURLlowercase = currentSlideURLname.replace(/\s+/g, '-').toLowerCase();
// if ("pushState" in history)
if (("pushState" in history) && (currentSlideURLlowercase !== "home"))
history.pushState("", currentSlideURLname, currentSlideURLlowercase);
else if (("pushState" in history) && (currentSlideURLlowercase === "home"))
history.pushState("null", "null", "/");
else {
// Prevent scrolling by storing the page's current scroll offset
scrollV = document.body.scrollTop;
scrollH = document.body.scrollLeft;
loc.hash = "currentSlideURLlowercase";
// Restore the scroll offset, should be flicker free
document.body.scrollTop = scrollV;
document.body.scrollLeft = scrollH;
}
});
// My Journey
// When the my journey page is loaded, tap the my journey link
setTimeout(function() {$("a[data-ix='clk-myjourney']").click();}, 1);
});
</script>
Thanks so much coder guys