-5

How to find the device width using the view port meta tag.

Also wants to display the device width in the console with

java script.

4
  • Can you post the code you tried? Commented Mar 19, 2013 at 9:20
  • you don't find the device width using the view port meta tag. and a simple google search would easily show you how to do it
    – kennypu
    Commented Mar 19, 2013 at 9:20
  • 1
    @SamuelLiew, device width != browser width Commented Mar 19, 2013 at 9:22
  • @SamuelLiew, screen.width (the width of the device's screen) vs window.innerWidth (the width of the browser window). They shouldn't be the same unless the window is maximized / fullscreen. Commented Mar 19, 2013 at 9:40

1 Answer 1

0

The viewport dimensions can be gotten through the window object:

var viewport = {
    width  : $(window).width(),
    height : $(window).height()
};

//can access dimensions like this:
//viewport.height

Though you won't always get perfect results, different devices behave differently and this gives the viewport dimensions, not the screen dimensions.

Refer this post more details on how to check the width of a data-role="page" element to find the device-width

Not the answer you're looking for? Browse other questions tagged or ask your own question.