Categories
Code

Mobile/responsive opt-out by setting the viewport

A colleague of mine was working on a site whereby we had a mobile view, but the client also wanted a link that would opt the user out and return users who are on the mobile view to the desktop view. This seems to have no logic what so ever, however that’s clients for you. We worked together for a good few hours trying to fix this problem. Removing the viewport meta tag using JavaScript/jQuery, changing & setting different attributes within the viewport meta tag but to no avail.

In the end, through trial and error we discussed that if we simply set the content attribute within the viewport meta tag to nothing, i.e:

$('meta[name=viewport]').attr('content','');

That it successfully returns the users mobile device back to the desktop view! Beer was needed after this discovery!!