FIX for "Bing Search returns to the top" !

Stop doing weird things, Bing ;)

< Părere la script-ul FIX for "Bing Search returns to the top" !

Întrebare/comentariu

§
Postat în: 07-08-2023

(function() {
'use strict';

// Disable the scroll to top functionality
function disableScrollToTop() {
window.scrollTo = function(x, y) {
if (y !== 0) {
window.scrollTo.originalFunc(x, y);
}
};
window.scrollTo.originalFunc = window.scrollTo;
}

// Listen for 'focus' events on the window
window.addEventListener('focus', disableScrollToTop);
})();

作者,你好,以上是你的源码。
window.scrollTo.originalFunc = window.scrollTo;这一行代码写在这里会有些问题,导致window.scrollTo.originalFunc并没有存储源scrollTo方法,而是你修改后的方法,那么脚本生效之后,调用window.scrollTo会导致堆栈溢出。
希望可以修复该bug。

Postează un raspuns

Autentifică-te pentru a posta un răspuns.