简体   繁体   English

JavaScript滚动元素可在Chrome中使用,但不能在IE11中使用

[英]JavaScript scroll over element works in Chrome but not in IE11

I'm writing an e2e test with selenium C# 我正在用硒C#编写e2e测试

I need to scroll to the bottom of a kendo-grid scrollbar element (scrolling any other element like grid body does not seem to work). 我需要滚动到kendo-grid滚动条元素的底部(滚动其他任何元素,例如网格体似乎都行不通)。 The code that does that is: 这样做的代码是:

$('div.k-scrollbar-vertical')[0].scrollTo(0,12000)

Works fine in Chrome console and via IJavaScriptExecutor in C#, but trying it in IE11 raises an error: 在Chrome控制台中以及通过C#中的IJavaScriptExecutor可以IJavaScriptExecutor ,但是在IE11中尝试会出现错误:

Object doesn't support property or method 'scrollTo'

Is there any way I can make it compatible to both browsers or any workaround? 有什么办法可以使其兼容两种浏览器或任何替代方法?

Why not use the more supported mechanism? 为什么不使用更多受支持的机制?

const o = document.querySelector('div.k-scrollbar-vertical')
o.scrollTop = o.scrollHeight

And if const is not supported in your version, you can use var 如果您的版本不支持const则可以使用var

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jQuery / Javascript函数适用于Chrome但不适用于IE11 - jQuery/Javascript function works in Chrome but not IE11 click()在Chrome中工作正常,但在IE11中工作不正常 - click() works fine in Chrome but not in IE11 Javascript代码可在IE11中运行,但不能在Chrome中运行 - Javascript code working in IE11 but not in Chrome 为什么页面微调器JavaScript在IE11中不起作用,但在Chrome和FireFox中起作用? - Why is page spinner JavaScript not working in IE11, but works in Chrome and FireFox? 优良的上载器异步任务在Chrome中有效,但在IE11中不起作用 - Fine uploader Async task works in Chrome but not in IE11 jQuery 在 IE11 中不起作用,但在 Chrome 中有效 - jQuery does not work in IE11, but works in Chrome 为什么此javascript无法在Windows 8.1的IE11上运行? (它适用于最新版本的Firefox,Chrome甚至Windows 7的IE11) - Why does this javascript NOT work on Windows 8.1's IE11? (It works on the latest version of Firefox, Chrome, even Windows 7's IE11) 在 Chrome 中但不是在 IE11 中的 dispatchEvent - dispatchEvent in Chrome but not in IE11 确认“删除Javascript”消息未显示在“ IE11”和“ Chrome”上 - Confirm Delete Javascript message not getting displayed on 'IE11' and 'Chrome' Javascript代码可在IE11上运行,但不能在Safari和Chrome上运行 - Javascript code runs on IE11 but not on Safari and Chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM