Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.navigator or just navigator?

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?

like image 789
J_z Avatar asked Nov 14 '11 12:11

J_z


People also ask

What is window navigator?

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.

What is the use of navigator?

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.

Is navigator userAgent deprecated?

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.

What is navigator standalone?

Navigator.standalone. Returns a boolean indicating whether the browser is running in standalone mode. Available on Apple's iOS Safari only.


2 Answers

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.

like image 106
Andy E Avatar answered Oct 31 '22 20:10

Andy E


you can use this ....

 alert("You're using " + navigator.appName);

for reference pls go through this link navigator

like image 35
Glory Raj Avatar answered Oct 31 '22 18:10

Glory Raj