4 Replies - 1011 Views - Last Post: 12 March 2013 - 01:31 PM

#1 enemeth  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-March 13

back to top when clicked

Posted 12 March 2013 - 10:46 AM

hello,

I need a way to get the page to load to the top of the page when a link is clicked, i have frames in my code and the menu goes down the page but when someone clicks on one of the links at the bottom of the page when the page loads it stays focused on the bottom of the page, i want it to automatically go to the top of the page on each link... can someone help?

thanks a bunch,
Elaine
Is This A Good Question/Topic? 0
  • +

Replies To: back to top when clicked

#2 Koyume  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 89
  • Joined: 19-February 13

Re: back to top when clicked

Posted 12 March 2013 - 12:18 PM

At the top of your page, add this.

<a name="top"></a>


And when you need to reference back to the top, I believe (if I remember correctly), you have to add #top to the end of your link. Say your link is boom.htm. Your link would look like this.

<a href="boom.htm#top">Boom! Headshot!</a>


This is untested though, but try it nonetheless.
Was This Post Helpful? 0
  • +
  • -

#3 enemeth  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-March 13

Re: back to top when clicked

Posted 12 March 2013 - 12:24 PM

Thank you so much it worked ! much appreciated !!!

Elaine ;)
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3823
  • View blog
  • Posts: 13,553
  • Joined: 12-December 12

Re: back to top when clicked

Posted 12 March 2013 - 01:03 PM

View PostKoyume, on 12 March 2013 - 12:18 PM, said:

At the top of your page, add this.

<a name="top"></a>


And when you need to reference back to the top, I believe (if I remember correctly), you have to add #top to the end of your link. Say your link is boom.htm. Your link would look like this.

<a href="boom.htm#top">Boom! Headshot!</a>


This is untested though, but try it nonetheless.

This is the old-skool way of doing this and involves the creation of a redundant A-link. Links can now refer to IDs so a better way to do this is to add an ID to the BODY tag:

<body id="top">

you could omit the page-name if jumping within the same page:
<a href="#top">Headshot!</a>


If your BODY has a top margin then you can add the ID to the HTML tag:

<html id="top">

but it even works just using the "#", without an ID:
<a href="#">To top</a>

although, this may require testing in very old browsers.

This post has been edited by andrewsw: 12 March 2013 - 01:04 PM

Was This Post Helpful? 1
  • +
  • -

#5 enemeth  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-March 13

Re: back to top when clicked

Posted 12 March 2013 - 01:31 PM

it worked perfectly :) thanks a bunch!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1