I am looking for a way to do a real-time test for scrollIntoView
functionality of my user's browser. This is not a "caniuse" check; rather I want to have graceful degradation. I am using jQuery, and would like to use a preventDefault()
if scrollIntoView is functional.
I started with:
if (window.scrollIntoView) {
e.preventDefault();
$('p#result').text('scrollIntoView is available');
} else {
$('#result').text('scrollIntoView is not available');
}
but I see that window.scrollIntoView
is undefined
in the inspector. However, because scrollIntoView
works (in my version of Chrome and FireFox), it shouldn't be undefined. What other options can I have to see if it the user's browser supports the function?
window
does not have this method – Gavrilla