$(" HTML&QUOT)。scrollLeft(值);不在Chrome中工作 [英] $("html").scrollLeft(value); not working in Chrome

查看:69
本文介绍了$(" HTML&QUOT)。scrollLeft(值);不在Chrome中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在页面加载时使浏览器水平滚动到特定位置。它适用于FF和IE,但不适用于Chrome。

I'm trying to make the browser scroll horizontally to a specific position when the page loads. It works in FF and IE, but not Chrome.

 $(document).ready(function () {
 $("html").scrollLeft(100);
 });

任何想法?

我的更大目标是让浏览器居中于水平滚动条。我再次使用FF和IE,但没有Chrome。

My larger goal is to have the browser center the horizontal scrollbar. Again, I have it all working in FF and IE, but no Chrome.

我所有其他方法在Chrome中运行良好。我正在使用以下方法来查找要滚动的像素数量,以便我可以将它居中,它们都可以正常工作,但是当尝试使用scrollLeft时它什么也没做。

All my other methods are working fine in Chrome. I'm using the following methods to find the amount of pixels to scroll so I can center it, and they all work right, but when it comes to try and use "scrollLeft" it does nothing.

$(document).width()
screen.width)
$(window).width()


推荐答案

请使用

$(window).scrollLeft(100);

$(document.body).scrollLeft(100);

这篇关于$(" HTML&QUOT)。scrollLeft(值);不在Chrome中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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