Navigator Object
The Navigator object contains information about the browser and is typically used to detect the version of the browser and operating system.
Object properties:
To view the browser name and version, the code is as follows:
<script type= "Text/javascript" > var browser=navigator.appname; var b_version=navigator.appversion; document.write ("Browser name" +browser); document.write ("<br>"); document.write ("Browser version" +b_version);</script>
UserAgent
<!DOCTYPE HTML><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Navigator</title><Scripttype= "Text/javascript"> functionValidb () {varu_agent=window.navigator.userAgent; varB_name="not want to use the mainstream browser!"; if(U_agent.indexof ("Firefox")>-1) {B_name="Firefox"; }Else if(U_agent.indexof ("Chrome")>-1) {B_name="Chrome"; }Else if(U_agent.indexof ("MSIE")>-1&&U_agent.indexof ("Trident")>-1) {B_name="IE (8-10)"; } document.write ("Browser:"+B_name+"<br>"); document.write ("u_agent:"+u_agent+"<br>"); } </Script></Head><Body> <form> <inputtype= "button"value= "View Browser"onclick= "Validb ()" > </form></Body></HTML>
Screen Object
Screen Object
The screen object is used to get the user's onscreen information.
Grammar:
Window.screen. Properties
Object properties:
Height and width of screen resolution
The Window.screen object contains information about the user's screen.
1. Screen.height returns the high screen resolution
2. Screen.width returns the width of the screen resolution
Attention:
1. Units are measured in pixels.
2. The Window.screen object can be written without using the window prefix.
Let's get the height and width of the screen, the code is as follows:
<script type= "Text/javascript" > document.write ("screen width:" +screen.width+ "px<br/>"); document.write ("screen height:" +screen.height+ "px<br/>");</script>
Screen available high and wide
1. The Screen.availwidth property returns the width of the visitor's screen, in pixels, minus interface features such as the taskbar.
2. The Screen.availheight property returns the height of the visitor's screen, in pixels, minus interface features such as the taskbar.
Attention:
The taskbar's default height is not the same on different systems, and the taskbar position can be anywhere on the screen, so it's possible that the width and height are not the same.
Let's get the available height and width of the screen, the code is as follows:
<script type= "Text/javascript" >document.write ("Available width:" + screen.availwidth);d ocument.write ("Available height:" + Screen.availheight);</script>
JS----Navigator Object, view browser information, screen object, view information