Learn, Share, Build

183
October 05, 2017, at 6:27 PM

I have a question, I would like to trigger a specific event in javascript or jquery on a webpage. The page has an animation effect during page loads (the screen and content splits in two and slides open revealing the next content). This works fine when the content on the page fits and doesn't need to be scrolled. However when content needs to be scrolled, the effect doesn't look as good. Is there anyway to trigger an href to scroll back to the top of the page and THEN load the href link/target? In basic terms something like "on click scroll to top and then load link" Any help would be great! Thanks

Answer 1

One could use jquerys animate to scroll to the top, then if that finished redirect:

$("a").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow", ()=> location.href = this.href );
  return false;
});

try it

READ ALSO
Learn, Share, Build

Learn, Share, Build

Recently I am working on aspnet application but my found that my script is not working and don't know why even I tested in the fiddle

203
Learn, Share, Build

Learn, Share, Build

I have a messenger on PHP/js, imported to all pages of the websiteThe messenger works through ajax, checking for new messages each 5 seconds

238
Learn, Share, Build

Learn, Share, Build

I have started with firebase , but have run into an annoying problem for a whileWhen ever I create a database object with firebase

226
Learn, Share, Build

Learn, Share, Build

I using cleditor plugin in my project

178