Get the current frame's height and width:
var w = window.innerWidth; var h = window.innerHeight;
Click the button to display this frame's height and width.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//www .j a va 2s.c o m var w = window.innerWidth; var h = window.innerHeight; document.getElementById("demo").innerHTML = "Width: " + w + "<br>Height: " + h; } </script> </body> </html>
The innerWidth property returns the width of a window's content area.
The innerHeight property returns the height of a window's content area.
These properties are read-only.
Use the outerWidth and outerHeight properties to get the width/height of the browser window.
The innerWidth property returns a Number, representing the width and/or the inner height of the browser window's content area, in pixels.