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?
The navigator property of a window (i.e. window. navigator ) is a reference to a Navigator object; it is a read-only property which contains information about the user's browser. Since Window is a global object and it is at the top of the scope chain, so properties of the Window object such as window.
The navigator is in charge of maintaining the aircraft or ship's nautical charts, nautical publications, and navigational equipment, and they generally have responsibility for meteorological equipment and communications.
navigator. userAgent: Deprecated This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped.
Navigator.standalone. Returns a boolean indicating whether the browser is running in standalone mode. Available on Apple's iOS Safari only.
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.
you can use this ....
alert("You're using " + navigator.appName);
for reference pls go through this link navigator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With