1

I want some help with a little thing in html/javascript, how i can make a javascript code for detect the page width and height and when it is smaller than I want just pops a alert telling "press Ctrl -" to adjust. (I know how to do the message, only need help with the detection of page size)

Thanks!

user3306761
  • 119
  • 1
  • 5

3 Answers3

0

Fast code snippet for JQuery:

if ($(document).height() < minHeight || $(document).width() < minWidth) {
    // call popup
}

minHeight and minWidth are variables you should define.

terales
  • 3,116
  • 23
  • 33
0

If you want Ctrl - means you want browser height and width for large screen purpose when you press Ctrl - after that follow this step (easy way for get width,height)

Press F12 - > Click on Console -> now right side under search option [in fire bug window] type window.innerWidth then select window.innerWidth and press run button which is exact under this window (bottom) and  check in console [bottom] browser print window.innerWidth. Do same for get window.innerHeight
user3302090
  • 177
  • 3
0

Try below solution to detect the page width and height

var pageWidth = document.documentElement.clientWidth,
    pageHeight = document.documentElement.clientHeight;
alert('Page Width '+pageWidth);
alert('Page Height '+pageHeight);

Fiddle Demo

Rakesh Kumar
  • 2,705
  • 1
  • 19
  • 33