Well it's not the perfect solutions but is suites my current needs.
First i will check if the native function is overridden with this helpful piece of code :
function isFuncNative(f) {
return !!f && (typeof f).toLowerCase() == 'function'
&& (f === Function.prototype
|| /^\s*function\s*(\b[a-z$_][a-z0-9$_]*\b)*\s*\((|([a-z$_][a-z0-9$_]*)(\s*,[a-z$_][a-z0-9$_]*)*)\)\s*{\s*\[native code\]\s*}\s*$/i.test(String(f)));
}
Source: https://stackoverflow.com/a/7536972/3009194
Then i will try the alternatives : window.scroll
as the is no difference between window.scroll() and window.scrollTo()
And finally if this one is also overridden, i guess i will use document.body.scrollTop
Yes i know, there is a possibility that the body is not the scrolling Element.
Unfortunately the document.scrollingElement
is still a draft and not supported in most browsers.
So the final code will look something like this:
function myScroll(left, top) {
if (isFuncNative(window.scrollTo)) {
window.scrollTo(left, top);
} else if (isFuncNative(window.scroll)) {
window.scroll(left, top);
} else {
document.body.scrollLeft = left;
document.body.scrollTop = top;
}
}
myScroll(0,150);