简体   繁体   中英

How can i get the window viewport size?

I tried to get the window viewport width. when i use document.documentElement.clientHeight(or)window.innerWidth i can get exactly what i need. If i logged In at minimize mode,then if i maximize the window the viewport width will not be resized.I got the viewport width when it is minimized. how can i slove it? I also tried to use document.body.clientHeight .But here also i got problem.The viewport size is larger than my viewport,because of statusbar.Then i subtract the statusbar size,then i got the viewport size.If i have anotherbar in my window again i got the same problem. Exactly what i need is how can get the end user viewport size?Please help me?

Thanks in advance

from the jQuery docs:

http://api.jquery.com/height/
http://api.jquery.com/width/

$(window).width();   // returns width of browser viewport
$(window).height();   // returns height of browser viewport

Try:

$myviewport.getHeight();
$myviewport.getWidth();

Where myviewport is the viewport OBJECT. You can also use:

Ext.getCmp('myviewport').getHeight();
Ext.getCmp('myviewport').getWidth();

Where 'myviewport' is the ID of the viewport object.

Use

.getHeight(true);
.getWidth(true);

To get the height/width minus padding, margins, borders etc.

As a consequence of the proliferation of different browsers' ideas about this, it's a surprisingly tricky thing to get right. David Mark (author of My Library ) is particularly strong in this area and has written an article on the subject: http://www.cinsoft.net/viewport.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM