开发者

how return to top button works

I have looked around many places return to top开发者_开发技巧 button .when i click on that that takes me to top of the page.

some time some links taking me to particular place how does this works

is this html tack ticks or javascript..can i do this without page loading ?


<a name="top">Top of the page</a> 
...
<a href="#top">return to top</a>

Note: HTML5 recommends using id="top" rather than name="top"


<a href="#top">return to top</a>

The #top bit refers to the id of an element that resides at the top of your page. In most cases this will be something like #header where you have:

<div id="header"></div>

at the top of the page. I'd suggest not using name as I believe the attribute is now deprecated.

Of course, to make it a little more fancy you could use something like: http://webdesignerwall.com/tutorials/animated-scroll-to-top


If you require to jump to a particular portion of the page by default during page than read on: Just append the id of the tag with URL. Eg: <div id='myID'>Some content</div>

Now if your URL ends with #myID than it shall jump to that portion automatically.


Lastly you can use javascript too:

<a href="#" onclick="document.getElementById('someId').scrollIntoView(); return false</a>

but assuming all modern browsers can do some id it is less needed nowadays

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜