FIX for "Bing Search returns to the top" !

Stop doing weird things, Bing ;)

< Feedback op FIX for "Bing Search returns to the top" !

Recensie: Redelijk - het script werkt, maar bevat bugs

§
Geplaatst: 26-08-2023

非常感谢,不过有一些bug
// Thank you very much, but there are some bugs

这个代码在直接调用window.scrollTo函数的时候可能导致栈溢出:
// This code may cause a stack overflow when calling the window.scrollTo function directly:

// 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;
}

可以用下面的代码替换:
// Can be replaced with the following code:

// Disable the scroll to top functionality
function disableScrollToTop() {
    let originalFunc = window.scrollTo;
    window.scrollTo = function(x, y) {
        if (y !== 0) {
            originalFunc(x, y);
        }
    };
}
§
Geplaatst: 05-12-2023

感觉好奇怪啊,originalFunc 在定义之前就被访问了,程序竟然可以正常运行。

It feels so strange. originalFunc is accessed before it is defined, but the program can run normally.

Reactie plaatsen

Log in om antwoord te geven.

长期地址
遇到问题?请前往 GitHub 提 Issues。