my.getWindowInfo

Obtain window information.

Supported SDK versions: 2.76.0 and the above versions

Supported types of mini programs: DSL

Sample code

See the following JavaScript sample code:

copy
const windowInfo = my.getWindowInfo();
console.log(windowInfo);

Return value

Note: In the following table, measurements are expressed in density‑independent pixels (dp) on Android and points (pt) on iOS, except for pixelRatio.

Property

Data type

Description

pixelRatio

Number

Device pixel ratio

screenWidth

Number

Screen width

screenHeight

Number

Screen height

windowWidth

Number

Window width

windowHeight

Number

Window height

statusBarHeight

Number

Height of the status bar

safeArea

Object

Safe area when the device is in upright portrait orientation

screenTop

Number

The Y-coordinate of the upper edge of the window

safeArea

Note: In the following table, measurements are expressed in density‑independent pixels (dp) on Android and points (pt) on iOS.

Property

Data type

Description

left

Number

X-coordinate of the top-left corner of the safe area

right

Number

X-coordinate of the bottom-right corner of the safe area

top

Number

Y-coordinate of the top-left corner of the safe area

bottom

Number

Y-coordinate of the bottom-right corner of the safe area

height

Number

Height of the safe area

width

Number

Width of the safe area