Skip to content

Instantly share code, notes, and snippets.

@louischan
Created February 8, 2019 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save louischan/3a13d55fa30b91f6d3b0fc12e7868135 to your computer and use it in GitHub Desktop.
Save louischan/3a13d55fa30b91f6d3b0fc12e7868135 to your computer and use it in GitHub Desktop.
Reset viewport in iPhone Safari

This JavaScript helper (bookmark) for iOS Safari helps you switch from fixed width mobile view to desktop view.

  1. In Safari, add a random web page to your bookmark

  2. Open bookmarks list, edit the newly added bookmark

  3. Change the bookmark name to "Zoom Out"

  4. Change the bookmark URL to javascript:var%20el=document.querySelector('meta%5Bname=viewport%5D');if(el)el.setAttribute('content','');

  5. Save the bookmark

Now, every time you visit a website (say, github.com) with fixed narrow viewport, you can switch to default ("desktop") viewport by tapping the bookmarks icon at the bottom of Safari and selecting the "Zoom Out" bookmark you created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment