[SOLVED][Drupal Colorbox] How to disable Colorbox for mobile browsers?

| | 1 min read

Many Drupal users have wanted to know how to disable Colorbox for mobile browsers. If you are looking for a way to disable Colorbox for mobile devices for your Drupal site then read on to find out the method to do that.

Here is how to do it.

  • You can disable Colobox via Javascript using the Colorbox off switch
  • $.colorbox.remove();
  • You can use the following jQuery as a template to disable Colorbox for a specific condition
    if (window.matchMedia) {
    
            // Establishing media check
    			width700Check = window.matchMedia("(max-width: 700px)");
    			if (width700Check.matches){
    				$.colorbox.remove();
    			}
    
        }
  • You can replace the conditions with practically anything like browser width, HD capabilities or day of the week.
  • The Colorbox link will revert back to an ordinary link and will link to the full sized image

Hope that helps.

The easiest way to solve a Drupal issue is to hand it to the Drupal experts. We can provide a wide range of Drupal services to help you maintain and manage your Drupal websites. Get in touch with us to know more.