rss icon icon icon icon icon icon

UN-Adaptive Web Design

Tuesday, 12 June, 2012

Last week a client of mine asked to have a responsive design in place of their current design, as the site is pretty big and recently built I decided to go adaptive and use mediaqueries to get the desired effect. All was going well until my client asked could we have a “view full site” link that you would see on a mobile site. Not everyone likes responsive and adaptive designs so I could see the clients point of view.

I decided jQuery would be the best way to attack the issue and experimented with several ideas until I came up with this:

function a_onClick() {
jQuery('link[rel=stylesheet][href~="http://example.com/mediaqueries.css"]').remove();
jQuery('meta[name=viewport]').remove();
jQuery('head').prepend('');
}

And for the HTML link to make it happen:

View Full Site

This basically removes the mediaqueries stylesheet and adds a different set of viewport choices when the link is clicked.

I also opted to hide the link on the “desktop” view:

#full {display:none;}

But wanted to show it on the re-sized pages:

#full {display:inline;}

Whilst it was a different kind of request I enjoyed the challenge of working around it (although it was a *slightly* hacky fix…)

If this helps someone out that’s awesome, BUT if someone knows a better way working around this please do feel free to share, if there is a “proper” solution to this I would love to try it out myself!

7 Comments

  • Jay Vincent - June 12, 2012

    Nice fix there Paul, although I’d prefer to see the onclick attribute removed from the html, ya’know, to keep js and html separate and all that :) You’ve got an id on that link so why not use that to hook on to:

    $(function() {
       $('#full').on('click', function(e) {
           e.preventDefault();
           //your function code here.
       });
    });
    

    Maybe you should think about setting a session variable to remember the user’s display preferences between new page loads.

    Jay.
    @letsallplaygolf

    Reply
    • Paul Maloney - June 12, 2012

      Cheers Jay, I didn’t think about hooking it to the ID.. that’s what frustration does to you it seems :P

      Definitely the next step would be a session variable of sorts! Thanks for the feedback and cleaner suggestion :)

      Reply
  • Andrew Champ - June 12, 2012

    Where’s the +1 button on this post?! ;)

    Reply
    • Paul Maloney - June 12, 2012

      I keep meaning to add some share buttons :P

      Reply
      • Andrew Champ - June 12, 2012

        There we go!!! w00t!

        Also, I didn’t get an email notification that you replied. Just sayin’.

        Reply
  • Russell Bishop - August 5, 2012

    Slick solution, although as mentioned above, you’d snap back to a responsive design as soon as a link was clicked!

    I tried something similar:
    http://russellbishop.co.uk/writes/code/responsive-web-design-opt-out/

    Reply
    • Paul Maloney - August 16, 2012

      Yeah that is the case! I did a small cookie and that seems to work a treat! Yours looks great, nice work! :)

      Reply

Leave A Comment