If you just change the layout, instead of CSS Media Queries .
In Chrome 7 and Firefox 3.6 there is a deviceorientation event that you can listen to.
In response to your comment, an easy way to detect tablets and phones is to determine the resolution and screen size. Tablets usually have a higher resolution display than phones. Media programs can determine these factors.
Regarding tablet options
If your device is a phone, you can switch CSS using Media Queries based on the orientation of the device.
If the device is a tablet, you can switch CSS using JS by switching body / class or by replacing style sheets.
source share