tags:

views:

61

answers:

2

top of the page focus

+1  A: 
document.location.href = "#"; 

will scroll back up, but will also add a '#' to your URL, but given the question, I could have just answered

functionToSetFocusOnTopOfPage();

and it would be just as good

Yanick Rochon
+1  A: 

It would be helpful if you write a little so that we can understand your problem.

A very easy way is linking to class or id on a page.

For example this page "page.html"

<body>
        <div id="top"> ..................Content................</div>
        <div id="otherdiv">........................</div>
</body>

then if you need to focus on top, send a link like "page.html#top" the page will automatically focus on top

or if you want to stick to javascript then do this

document.location.href = '#top'; //to send it to the top

But I would say use simple html anchor to go to top like

<a href="#top">Back to Top</a>

Starx