JS obtains the current webpage size and screen resolution. js currently
The effect is as follows:
The Code is as follows:
<Html>
The code is illustrated as follows:
How can I obtain the screen width of a mobile phone from a js webpage?
</Head>
<P id = "p1"> sssss </p>
<Body>
</Body>
</Html>
<Script>
Var x = navigator;
Var w = window. innerWidth
| Document.doc umentElement. clientWidth
| Document. body. clientWidth;
Var h = window. innerHeight
| Document.doc umentElement. clientHeight
| Document. body. clientHeight;
Document. getElementById ("p1 "). innerHTML = "<B> screen resolution: </B>" + screen. width + "*" + screen. height + "<B> internal window </B>:" + w + "*" + h
</Script>
I don't know if it is the screen resolution: the desktop Resolution on the pc. The mobile phone is a fixed resolution of the model, such
The resolution of Huawei 8813 is 480*854 .. The internal window is to change the window size. Refresh the window and there will be new data.
How does HTML obtain screen size?
<Html>
<Script>
Function (){
Document. write (
"Screen Resolution:" + screen. width + "*" + screen. height // preferably window. screen
+ "<Br/>" +
"Available screen size:" + screen. availWidth + "*" + screen. availHeight
+ "<Br/>" +
"Visible area width of the webpage:" + document. body. clientWidth
+ "<Br/>" +
"Visible area Height:" + document. body. clientHeight
+ "<Br/>" +
"Visible area width of the webpage (including the width of the edge):" + document. body. offsetWidth
+ "<Br/>" +
"Visible area height (including edge width):" + document. body. offsetHeight
+ "<Br/>" +
"Webpage text width:" + document. body. scrollWidth
+ "<Br/>" +
"Webpage text Height:" + document. body. scrollHeight
+ "<Br/>" +
"Webpage volume Height:" + document. body. scrollTop
+ "<Br/>" +
"Left of the webpage to be rolled:" + document. body. scrollLeft
+ "<Br/>" +
"Webpage body part:" + window. screenTop
+ "<Br/>" +
"Webpage body part left:" + window. screenLeft
+ "<Br/>" +
"Screen Resolution height:" + window. screen. height
+ "<Br/>" +
"Screen Resolution width:" + window. screen. width
+ "<Br/>" +
"Available screen workspace Height:" + window. screen. availHeight
+ "<Br/>" +
"Available screen workspace width:" + window. screen. availWidth
);
}
Function set_bgColor (){
Document. body. style. backgroundColor = "red ";
}
Function set_bgImg (){
Document. body. style. backgroundImage = "url (t/JS to get... the rest of the text>