Created
June 19, 2017 19:11
-
-
Save delphinpro/a962978d668b63e046889efd1073a67c to your computer and use it in GitHub Desktop.
Conditional meta viewport
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Paste into the end <head> | |
| */ | |
| (function(){ | |
| var width = screen.width; | |
| var oldViewport = document.querySelector('meta[name="viewport"]'); | |
| var viewport = document.createElement('meta'); | |
| viewport.setAttribute('name', 'viewport'); | |
| viewport.setAttribute('content', 'width=' + (width <= 640 ? '640' : 'device-width')); | |
| document.head.replaceChild(viewport, oldViewport); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment