Skip to content
Russell edited this page Sep 23, 2020 · 10 revisions

Welcome to the bookmarklets wiki!

Dynamic Viewport

Opens a prompt dialog box and expects a number. You could go higher than 1, but 0-1 should be suitable for most cases.

javascript:(function(meta){   if(document.getElementById('metaview')){  document.head.removeChild(document.getElementById('metaview'));  }  var io = prompt('Viewport Scale Between 0 and 1'),   meta.id = 'metaview';  meta.name = 'viewport';  meta.content = 'width=device-width, initial-scale=' + io + ', minimum-scale='+io+', maximum-scale='+io+', user-scalable=no';   window.document.head.appendChild(meta);   })(document.createElement('meta'));
/*
 * Dynamic Viewport
*/
(function(meta){ 
  
  if(document.getElementById('metaview')){ 
    document.head.removeChild(document.getElementById('metaview')); 
  }
  
  var io = prompt('Viewport Scale Between 0 and 1'), 
  
  meta.id = 'metaview'; 
  meta.name = 'viewport'; 
  meta.content = 'width=device-width, initial-scale=' + io + ', minimum-scale='+io+', maximum-scale='+io+', user-scalable=no'; 
  
  // top will likely throw an error
  // window.top.document.head.appendChild(meta); 
  
  // might get away with parent
  // window.parent.document.head.appendChild(meta);
  
  // this should work if it is executed in the url, not an embedded window
  window.document.head.appendChild(meta); 
  
})(document.createElement('meta'));

Clone this wiki locally