What object I should use to determine browser's info?
alert(window.navigator.userAgent);
or
alert(navigator.userAgent);
Is there any recomendations about cross-browser compatibility of a decision?
Either, it doesn't really matter. navigator
is a property of the window
object, but all properties of the window
object are accessible as global variables.
navigator === window.navigator;
//-> true
As a personal preference, I always write window.propertyName
for explicit properties of the window
object.