Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the properties of the JavaScript Screen object

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What are the properties of the JavaScript Screen object? in view of this question, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

The window.screen object is used to get information about the user's screen. The screen object is a property of the window object, which means "screen" in Chinese. Navigator objects are commonly used to get information about browsers and operating systems.

What are the properties of the JavaScript Screen object

Common properties of screen object

Attribute description

The height of the height screen, in pixels

The width of the width screen, in pixels

AvailHeight window can use the screen height, in pixels, minus interface features, such as the window taskbar.

AvailWidth window can use the screen width, in pixels, minus interface features, such as the window taskbar.

The number of color bits represented by the colorDepth user browser, usually 32 bits (bits per pixel)

The number of color bits represented by pixelDepth users' browsers, usually 32 bits per pixel (this attribute is not supported by IE)

For example, get the user's screen information:

?

one

two

three

four

five

six

seven

eight

nine

ten

Input id= "demo1" type= "button" value= "display screen Information" / >

Script type= "text/javascript" >

Document.getElementById ("demo1") .onclick=function () {

Alert (

"screen Information:\ n" +

"Resolution:" + screen.width+ "×" + screen.height+ "\ n" +

"availability zone:" + screen.availWidth+ "×" + screen.availHeight

)

}

/ script >

What are the properties of the JavaScript Navigator object

Since there is no uniform standard for navigator, each browser has its own version of navigator, and here only the most commonly supported and commonly used ones are introduced.

Common properties of navigator object

Property description IE FireFox Opera

AppCodeName returns the code name of the browser. 4 1 9

AppMinorVersion returns the minor version of the browser. 4 No No

AppName returns the name of the browser. 4 1 9

AppVersion returns the platform and version information of the browser. 4 1 9

BrowserLanguage returns the language of the current browser. 4 No 9

CookieEnabled returns a Boolean value indicating whether cookie is enabled in the browser. 4 1 9

CpuClass returns the CPU level of the browser system. 4 No No

OnLine returns a Boolean value indicating whether the system is in offline mode. 4 No No

Platform returns to the operating system platform on which the browser is running. 4 1 9

SystemLanguage returns the default language used by the operating system. 4 No No

UserAgent returns the value of the user-agent header of the server sent by the client. 4 1 9

UserLanguage returns the natural language settings of the operating system. 4 No 9

The most important thing in navigator is the userAgent property, which returns a string containing information such as the browser version, and cookieEnabled is also important, which can be used to determine whether the user's browser opens cookie.

Note that the information from the navigator object is misleading and should not be used to detect the browser version because:

Navigator data can be changed by browser users

The browser cannot report a new operating system released later than the browser.

For example, get client information:

?

Input id= "demo1" type= "button" value= "display browser information" / >

Script type= "text/javascript" >

Document.getElementById ("demo1") .onclick=function () {

Alert (

"browser Information:\ n" +

"name:" + navigator.appName+ "\ n" +

"platform and version:" + navigator.appVersion+ "\ n" +

"operating system:" + navigator.platform+ "\ n" +

"userAgent:" + navigator.userAgent

)

}

/ script >

This is the answer to the question about the properties of the JavaScript Screen object. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report