JS----Navigator Object, view browser information, screen object, view information

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.