Ask your Question

Write to us

Ask Question

Page Switch to Different page For Particular section

Ajeet Kumar Yadav

 Hello Guys Once Again I am sharing You the real life tech hacks while coding, One of my clients in my company asked for Linking a page to somewhere and scroll that particular section based on ID and URL matching, But I got stuck badly in scrolling that page on load of browser window , i put code from somewhere that was doing half work it was able to forward to that page and move to that section but was Not scroll-able. Also That code made a Huge Trouble To the Owl carousal finally i got that solution hope this code will help you a lot I have commented one single comment to remove do check that also //Page Scroll from footer for different location

(function ($)
 
{
 
var jump = function (e) {
 
if (e) { e.preventDefault(); var target = $(this).attr("href"); }
 
else {
 
var target = location.hash;
 
}
 
$('html,body').animate({ scrollTop: $(target).offset().top+-160 }, 1000, function ()
 
{ location.hash = target; });
 
}              //Please remove this code this could create hacks for OWL carsoul--> $('html, body').hide(); // $(document).ready(function ()
 
{
 
 $('a[href^=#]').bind("click", jump);
 
  if (location.hash)
 
{
 
   setTimeout(function () { $('html, body').scrollTop(0).show() jump(); }, 0);
 
}
 
else {
 
$('html, body').show(); } }); })(jQuery)
 
Do share Your views To Clarify what have You learn from above one. How Window URL on load is scrolling..... Let check You can Let me Know Better ......

Ajeet Kumar Yadav