Created
April 12, 2017 14:59
-
-
Save hadrianw/d6a0d3883a0e12e71dd8b09476161eae to your computer and use it in GitHub Desktop.
Bookrmarklet to add or modify meta viewport to allow resizing on mobile.
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
var d=document; | |
var q=d.querySelector.bind(d); | |
var c='width=device-width,initial-scale=1'; | |
var v=q('meta[name=viewport]'); | |
if(v){ | |
v.content=c | |
}else{ | |
v=d.createElement('meta'); | |
v.name='viewport'; | |
v.content=c; | |
q('head').appendChild(v); | |
} | |
// Bookmarklet version | |
/* | |
javascript:(function()%7Bvar%20d%3Ddocument%3Bvar%20q%3Dd.querySelector.bind(d)%3Bvar%20c%3D'width%3Ddevice-width%2Cinitial-scale%3D1'%3Bvar%20v%3Dq('meta%5Bname%3Dviewport%5D')%3Bif(v)%7Bv.content%3Dc%7Delse%7Bv%3Dd.createElement('meta')%3Bv.name%3D'viewport'%3Bv.content%3Dc%3Bq('head').appendChild(v)%3B%7D%7D)() | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment