| Author |
How to make a "back to top" feature?
|
Ziyang Zhang
Ranch Hand
Joined: Jul 17, 2010
Posts: 47
|
|
Hi All,
I have a log page and I want to add a back to top feature, so user can go back to the top of the page.
Could somebody tell me how to do this?
Thanks a lot.
Ziyang
|
Enjoy life!
|
 |
Marc Kruze
Greenhorn
Joined: Oct 28, 2010
Posts: 5
|
|
You could use anchor tags.
I solved this one by using the following code (may vary according to your requirements; this worked for what I had to do):
//This goes on the header
<script language="JavaScript">
function setFocus(componentId) {
var obj = document.getElementById(componentId);
if (obj != null) {
obj.focus(); }
}
</script>
Then on the onclick attribute make a call to setFocus passing the component ID.
I hope this helps.
|
 |
Jay pratt
Greenhorn
Joined: Oct 29, 2010
Posts: 2
|
|
There are two ways that I know of.
1) use an anchor tag in the page:
Link: <a href="#top">back to top</a>
Anchor tag placed at the top so the browser knows where to go: <a name="top"></a>
2) You can do it with Javascript: window.scrollTo(0,0)
|
 |
 |
|
|
subject: How to make a "back to top" feature?
|
|
|