Reputation: 63
Apologies if this has already been asked, but I couldn't find a specific solution.
I am using a set uneditable plugin
on my website
which uses pages. I cannot edit the code
for the plugin
. The paged content is towards the bottom of the page that it is displayed on: see here
When the user clicks on the pages, it adds "page/2/" etc to the end of the current URL, but it shows the user the top of the page.
I have added an anchor just before the plugin, but how can I scroll the user to the anchor based on if the URL contains "page/2/" or "page/3/" etc.?
Simply: If the URL contains the word "page", then scroll to #anchor
Thanks!
Upvotes: 0
Views: 1370
Reputation: 63
Got it working, thanks @hangindev
<script type="text/javascript">
if(window.location.href.indexOf("page") > -1) {
(function($) {
$(document).ready(function() {
$('html, body').animate({
'scrollTop': $('#anchor').offset().top
}, 1000);
});
})(jQuery);
}
</script>
Upvotes: 5
Reputation: 4572
Maybe this helps
<a href="#bottom">Bottom</a>
<h1 id="bottom">This is the bottom! </h1>
Upvotes: 0