首页 > 解决方案 > Scroll is not working for ie 11 sharepoint 2013

问题描述

I am trying to get the scroll position, the scroll is working in all the browser except ie 11.0

I have tried the below code this is not firing any event

 window.onscroll = function () {
    console.log("Test");
};

标签: javascriptjqueryinternet-explorersharepoint

解决方案


此问题与 IE 浏览器和 SharePoint 有关吗?

您上面的代码示例不足以重现问题。

我尝试使用此示例代码进行测试,看起来它在 IE 11 浏览器上运行良好。

<!DOCTYPE html>
<html>
<head>
	<title>Page Title</title>
	
	<style>
	#show {
    display:block;
    position:fixed;
    top:0px;
    left:300px;
	}
	</style>
</head>
<body>

<pre id="repeat"></pre>

<div style="position:relative;">
    <div id="show">x</div>
</div>
<script>
	var elem = document.getElementById('repeat');
	var show = document.getElementById('show');

	for (i = 1; i <= 300; i++) {
    	elem.innerHTML += i + "<br/>";
	}


	window.onscroll = function () {
    	show.innerHTML = document.documentElement.scrollTop || document.body.scrollTop;
	};
	</script>
</body>
</html>

IE 11 中的输出:

在此处输入图像描述

参考:

为什么窗口滚动事件不起作用?

如果您的问题仍然存在,请尝试提供一个清晰的示例,其中包含可能产生问题的详细步骤。我们将尝试对其进行测试以检查结果。


推荐阅读