使用jQuery滚动插件来避免在URL上出现#号 [英] Use jQuery scroll plugin to avoid # on url

查看:120
本文介绍了使用jQuery滚动插件来避免在URL上出现#号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用滚动jQuery插件滚动到anchor tag,因为当您单击链接时,我不想浏览器在URL末尾添加#. 我不希望任何人使用#.

I want to use scroll jQuery plugin to scroll to anchor tag because I don't want to browser to add # to the end of url when you click links.
I don't want anyone to bookmark url of my web site with #.

<html>
    <body>
        <a name="top"></a>TOP
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        <a href="#top">top</top>
    </body>
</html>


jQuery.ScrollTo是最标准的插件吗?
http://demos.flesler.com/jquery/scrollTo/

我想支持IE6,FF4,Chrome,Android和iphone.
jQuery.ScrollTo是否支持它们?
或者如果我需要浏览器兼容性,我不应该使用滚动插件吗?


Is jQuery.ScrollTo the most standard plugin to do that?
http://demos.flesler.com/jquery/scrollTo/

I want to support IE6, FF4, Chrome, Android, and iphone.
Does jQuery.ScrollTo support them?
Or shouldn't I use the scroll plugin if I need browser comatibility?

推荐答案

您不需要插件,并且可以通过scrollTop为用户提供流畅的滚动效果(此处为实时示例-

You don't need a plugin + give your users a nice smooth scroll with scrollTop (live example here - http://jsfiddle.net/7qr3y/9/ ):

HTML:

<a href="#" class="bottomscroll">bottom</a>

jQuery:

$('.bottomscroll').click(function() {
     $('html, body').animate({ scrollTop: $('#bottom').offset().top }, 'slow');
     return false;
 });

这篇关于使用jQuery滚动插件来避免在URL上出现#号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆