jquery地址插件干扰scrollTo值

发布于 2024-09-24 01:44:37 字数 280 浏览 3 评论 0原文

我建立了一个基于 ajax 的网站,它利用地址 jquery 插件来实现后退按钮浏览器兼容性。然而,由于页面是通过ajax页面获取的,因此传统的页面刷新并不明显,并且在用户导航等方面相当迷失方向。用户单击链接,ajax获取页面,虽然成功并且页面在屏幕上获取,但屏幕不会出现在顶部特别是当窗口较长并且单击的链接位于源页面的最底部时。仿佛一切都没有改变。我尝试使用scrollTo插件,但测试时窗口scrollTop值始终为0和零,删除地址插件后,scrollTop值现在被读取。

有人遇到过同样的问题吗?

先感谢您!

I've built an ajax-based website that utilizes the address jquery plugin for back forward button browser compatibility. However, since pages are fetched via ajax page conventional page refresh is not obvious and rather disorienting in terms of user navigation etc. User clicks a link, ajax fetches the page, although successful and page is fetched on screen, screen will not go on top of the page especially when the window is longer and clicked link was at the very bottom of the source page. As if nothing has changed. I've attempted to use scrollTo plugin but window scrollTop value upon testing is 0 and zero all the time, removing the address plugin the scrollTop value is now read.

Has anyone encountered the same issue?

Thank you in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

煮酒 2024-10-01 01:44:38

我遇到了完全相同的问题,尝试了几种滚动到顶部的方法,最终删除了滚动到顶部按钮。

现在我一直在用 iPhone 测试我的网站(使用 Bootstrap 响应式),我发现只有页面顶部会显示,而且我根本无法滚动。

这两个问题似乎都与换行选项有关,该选项对页面做了一些奇怪的事情。

我修复它的方法是在页面中导入 jquery.address.js 文件时添加一些额外的参数:

<script type="text/javascript" src="/script/jquery-address/jquery.address.js?strict=false&wrap=false"></script>

注意 ?strict=false&wrap=false

这似乎对我有用:)
我希望它有帮助!

I had exactly the same problem, tried several ways to scroll to top and i ended up removing the scroll to top button.

Now i have been testing my website with iphone (using bootstrap responsive) and i found out that only the top of the page would be displayed and i wasnt able to scroll at all.

Both issues seems to be related to the wrap option which does something weird to the page.

What i did to fix it was to add some extra parameters when importing the jquery.address.js file in the page:

<script type="text/javascript" src="/script/jquery-address/jquery.address.js?strict=false&wrap=false"></script>

notice the ?strict=false&wrap=false

This seems to work for me :)
I hope it helps!

墨小沫ゞ 2024-10-01 01:44:37

看看

$.address.wrap(value)

http://www.asual.com/jquery/address /docs/#api-reference

或者您可以使用 jquery animate 向上滚动。我之前所做的是设置滚动动画,然后更改 $.address.value。像这样:

$('a').click(function(e){
    e.preventDefault();
    var a = $(this);
    $('html').animate({ scrollTop: 0 }, 100, function () {
        $.address.value(a.attr('href'));
    });
});

Take a look at

$.address.wrap(value)

http://www.asual.com/jquery/address/docs/#api-reference

Or you can use the jquery animate to scroll up. What I've done before is animate the scroling and then change the $.address.value. Like this:

$('a').click(function(e){
    e.preventDefault();
    var a = $(this);
    $('html').animate({ scrollTop: 0 }, 100, function () {
        $.address.value(a.attr('href'));
    });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文