scrollTop doesn't scroll on Chrome 61

在chrome61 不支持滚动 解决方案:

Use document.scrollingElement if supported, and fall back to the current code.

For example, if the current (problematic) code is something like:

function bodyOrHtml() => {
	if (navigator.userAgent.indexOf(‘WebKit‘) != -1) {
		return document.body;
	}
	return document.documentElement;
}
...
bodyOrHtml().scrollTop = 100;

下面是最好的解决方法:

function bodyOrHtml() => {
	if (‘scrollingElement‘ in document) {
		return document.scrollingElement;
	}
	// Fallback for legacy browsers
	if (navigator.userAgent.indexOf(‘WebKit‘) != -1) {
		return document.body;
	}
	return document.documentElement;
}
...
bodyOrHtml().scrollTop = 100;

参考:https://dev.opera.com/articles/fixing-the-scrolltop-bug/

scrollTop doesn't scroll on Chrome 61

时间: 2024-07-28 14:44:47

scrollTop doesn't scroll on Chrome 61的相关文章

Element is not clickable at point error in chrome

I see this only in Chrome. The full error message reads: "org.openqa.selenium.WebDriverException: Element is not clickable at point (411, 675). Other element would receive the click: ..." The element that 'would receive the click' is to the side

javascript中的scroll事件

window.addEventListener('scroll',function(){ if(document.compatMode == "CSS1Compat") { alert(document.documentElement.scrollTop); } else { alert(document.body.scrollTop); } },false); 虽然scroll事件是在window对象上发生的,但它事件表示的则是页面中相应元素的变化.在混杂模式中,可以通过<bo

jQuery中animate()方法以及$(&#39;body&#39;).animate({&quot;scrollTop&quot;:top})不被Firefox支持问题的解决

$("body").animate({"scrollTop":top}): 只被chrome支持,而不被Firefox支持 $("html").animate({"scrollTop":top}): 只被Firefox支持,而不被chrome支持. 如果想让这段js被chrome和Firefox都支持的话,应该这样: $("html,body").animate({"scrollTop"

Android通过Chrome Inspect调试WebView的H5 App出现空白页面的解决方法(不需要FQ)

调试基于WebView的Hybrid App最舒服的工具当然是Chrome自带的开发者工具,其中有我们熟悉的Dom树调试,JS调试,Network监视等等功能. Google提供的调试Android上WebView的步骤: 开启手机上的USB调试功能 打开Chrome浏览器,地址栏输入:Chrome://inspect,回车 Chrome会自动检测手机上打开的App,并列出可调试的WebView页面,如图: 点击Inspect,弹出开发者工具进行调试 问题就出现在这里,对于国内的程序猿来说,由于

一次日语翻译的Chrome插件开发经历

序言 去年7月刚过了日语N2,想着今年考个N1,为了加深日语文化的了解,还有学习日语,平时免不了经常上日语网站. 但是毕竟水平有限,所以不免遇到不认识的单词,日语单词的一个特点就是很多单词你知道是什么意思,但是不知道怎么读. 比如:"簡素な構造" 中的第一个词:"簡素",很显然就是"简单,朴素的意思",但是你肯定不知道它的读音是:"[かんそ]①". 以前遇到这样的词的时候,就会在沪江小D网页版上面查询,但是这样特别麻烦,你要跳

Headless Chrome入门

原文地址:Getting Started with Headless Chrome  By EricBidelman  Engineer @ Google working on web tooling: Headless Chrome, Puppeteer, Lighthouse Headless Chrome在Chrome59中发布,用于在headless环境中运行Chrome浏览器,也就是在非Chrome环境中运行Chrome.它将Chromium和Blink渲染引擎提供的所有现代Web平台

JS—实现拖拽

JS中的拖拽示例:    1)实现拖拽思路:当鼠标按下和拖拽过程中,鼠标与拖拽物体之间的相对距离保持不变    2)实现拖拽遇到的问题:        问题1:当鼠标按下移动过快时,离开了拖拽的物体时,这时拖拽物体将不再随着鼠标移动                因为拖拽的div太小了,这时我们可以将在拖拽物体上的mousemove事件放到document上面                同时将mouseup也改为document上面的事件                IE下直接用obj.s

【JavaScript 封装库】BETA 3.0 测试版发布!

1 /* 2 源码作者: 石不易(Louis Shi) 3 联系方式: http://www.shibuyi.net 4 =================================================================================================== 5 程序名称: JavaScript 封装库 BETA 3.0 版 6 迭代版本: BETA 2.0 7 插件总数: 8 个 8 库方法数: 20 个 9 功能总数: 48 个

jquery css快捷方法

1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>wrap</title> 6 <script type="text/javascript" src="../jquery/jquery-1.11.3.min.js"></scrip