Can someone help with some HTML code please?

  • 1
  • Question
  • Updated 7 years ago
  • Answered
Hi there

I was wondering if someone can help with a HTML code. I want one of those buttons that says 'go back to the top' or 'top of page' or something like that. So when you click it you go to the top of the page.

Let me know ;)

Website: www.helderbergads.com

Bernhardt
Photo of Bernhardt

Bernhardt

  • 70 Posts
  • 0 Reply Likes
  • confident

Posted 7 years ago

  • 1
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
Hey Bernhardt,

I'm good with HTML, CSS and JavaScript! I can help you!

I'm going to give you a code to make it actually slide to top animated,a nd not just go to the top, because when it just goes to the top, no one knows if they went to a new page or what. So this will actually scroll the scroll bar up when you click the link!

Step One: Add this code in an HTML widget to the top of your page:



<!--

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/...>
<script type="text/javascript">
$(document).ready(function() {

$('a[href=#top]').click(function(){

$('html, body').animate({scrollTop:0}, 'slow');

return false;

});

});
</script>

-->



(But don't copy the <!-- or the -->)

Step Two: Add this code into an HTML widget wherever you want the Back to Top link to be:



<a href="#top" onclick="return false">Scroll to Top ▲</a>



Thats it! You only have to add the first code once, and you can add the second one wherever you want and as much times as you want!

Here's a test page: http://tester3.yolasite.com/scroll-to...

I hope this helps!

Nathan
Photo of Brianna

Brianna

  • 2045 Posts
  • 92 Reply Likes
Thanks for the help, Nathan!
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
No problem!
Photo of Bernhardt

Bernhardt

  • 70 Posts
  • 0 Reply Likes
Woah ... hehe... check this out... Nathan you are the BEST!!

www.helderbergads.com

Please scroll down and click on my newly added button... FANTASTIC. Just what I was looking for!!

I am soon going to buy Yola Silver. I am so impressed with Yola...

Great Work!!
Photo of Nazlie

Nazlie

  • 1721 Posts
  • 51 Reply Likes
That looks awesome on your website, Bernhardt! Great work, Nathan. Definitely a good tip about scrolling up the same page.

Nazlie
Photo of Bernhardt

Bernhardt

  • 70 Posts
  • 0 Reply Likes
Thanks Nazile... This 'crazy' button will come in very handy as soon as my updates are finished, I am waiting for permissions to show some content on my website and as soon as I get the thumbs up my main page will be full of stories and that means you don't want to scroll up... You will now just click on that amaizing button...

Bernhardt :)
Photo of Nathan

Nathan, Champion

  • 3739 Posts
  • 307 Reply Likes
Awesome! I'm so glad it helped :)

And don't forget you can add that second smaller code as much as you want and anywhere you want on the page!

Nathan
Photo of Mike

Mike

  • 192 Posts
  • 4 Reply Likes
Once again SuperNathan saves the day. :) Keep up the nice work.