Media Query detection on windows mobile

if (window.matchMedia("(min-width: 320px)").matches) {
    alert("width 320"); // works
if (window.matchMedia("(min-width: 768px)").matches) {
    alert("width 768");
if (window.matchMedia("(min-resolution: 2.4dppx)").matches) {
if (window.matchMedia("(min-resolution: 217dpi)").matches) {
    dpi = 217;
if (window.matchMedia("(min-resolution: 252dpi)").matches) {
    dpi = 252;
if (window.matchMedia("(min-resolution: 331dpi)").matches) {
    dpi = 331;
if (window.matchMedia("(min-resolution: 332dpi)").matches) {
    dpi = 332;

I'm testing on Lumia 920 and only width 320 works, none other, I want to know the DPI. Tried everything, its just min-resolution that doesn't work.


I think this is because you have only min-width defined. if you are searching for min-width:320px - this query is met always - even you have bigger resolution. Try something like

if (window.matchMedia("(min-width: 320px) and (max-width: 767)").matches) {
    alert("width 320"); // works
}//one px less then the query in next statement

Need Your Help

Using iAds to purchase new apps?

iphone objective-c cocoa-touch iad

I am making an iAd for my app, and I want to know if it is possible to allow users to purchase the full version of it using my iAd. Basically, these are the steps the user will need to take:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.