Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Modal windows for mobile

Hi there,

I'm using twitter bootstrap and I have a dilemma with the modal. I would like to disable the modal for smaller screen sizes and instead have a link to go to a new page.

So far I have it so if javascript is disabled then it goes to another page but I cannot figure out how to totally disable it for smaller screen sizes...

Any thoughts on how to accomplish this??

Thanks in advance.

1 Answer

Well, it's fairly simple, use the "class" from the code. P.S : I haven't written this, maybe I've adapted or just copied something existing, can't really remember.

And with jQuery remove all the "modal" triggers if it's a mobile device, just reply here if you can't manage it. Would gladly help

var checkMobile : {
  Android: function() {
    return navigator.userAgent.match(/Android/i);
  },
  BlackBerry: function() {
    return navigator.userAgent.match(/BlackBerry/i);
  },
  iOS: function() {
    return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  },
  Opera: function() {
    return navigator.userAgent.match(/Opera Mini/i);
  },
  Windows: function() {
    return navigator.userAgent.match(/IEMobile/i);
  },
  any: function() {
    return (this.Android() || this.BlackBerry() || this.iOS() || this.Opera() || this.Windows());
  }
 };

Thanks for your reply!