| |

VerySource

 Forgot password?
 Register
Search
View: 680|Reply: 3

How to get the actual width of a page with js

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-8 17:00:01
| Show all posts |Read mode
The problem is this. I use js to get the page width. This page is embedded through an iframe. I use js code to get the width of this page. Also take out the width of the hidden part? document.body.offsetWidth gets the width of the visible area. It seems that there is no width hidden by the scroll bar.
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-31 17:15:01
| Show all posts
document.body.scrollWidth
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-31 22:15:01
| Show all posts
<script type = "text / javascript" language = "javascript">
var s = "";
s + = "\r\n page visible area width:" + document.body.clientWidth;
s + = "\r\n web page visible area height:" + document.body.clientHeight;
s + = "\r\n page visible area width:" + document.body.offsetWidth + "(including the width of the border)";
s + = "\r\n web page visible area height:" + document.body.offsetHeight + "(including the width of the border)";
s + = "\r\n full text page width:" + document.body.scrollWidth;
s + = "\r\n The full text of the web page height:" + document.body.scrollHeight;
s + = "\r\n webpage is scrolled high:" + document.body.scrollTop;
s + = "\r\n left page scrolled:" + document.body.scrollLeft;
s + = "\r\n on the body of the page:" + window.screenTop;
s + = "\r\n left part of the body of the webpage:" + window.screenLeft;
s + = "\r\n high screen resolution:" + window.screen.height;
s + = "\r\n screen resolution width:" + window.screen.width;
s + = "\r\n screen available workspace height:" + window.screen.availHeight;
s + = "\r\n screen available workspace width:" + window.screen.availWidth;
alert (s);
</ script>
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-4-2 10:45:01
| Show all posts
Thank you.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list