title: Change meta viewport tag if android or iphone
body: <p>I want to change the meta viewport tag based on detection of an android or an iphone. I have this code but it is not working:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var metas = document.getElementsByTagName('meta');
  var i;
  var ua = navigator.userAgent;
  
  var isAndroid = navigator.userAgent.match(/Android/i) !=null;
  var isAndroid = /Android/i.test(ua);
  
  var isiPhone = navigator.userAgent.match(/iPhone/i) !=null;
  var isiPhone = /iPhone/i.test(ua);
  
  if(isiPhone) {
  for (i=0; i&lt;metas.length; i++) {
    if (metas[i].name == "viewport") {
      metas[i].content = "";
    }
  }
  } else if(isAndroid) {
  for (i=0; i&lt;metas.length; i++) {
    if (metas[i].name == "viewport") {
      metas[i].content = "";
    }
  }
  } else {
  for (i=0; i&lt;metas.length; i++) {
    if (metas[i].name == "viewport") {
      metas[i].content = "width=device-width, initial-scale=.5";
    }
  }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I tried this code as a test and it works just fine:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var isiPad = navigator.userAgent.match(/iPad/i) != null;
  var ua = navigator.userAgent;
  var isiPad = /iPad/i.test(ua) || /iPhone OS 4_3_3/i.test(ua) || /iPhone OS 4_3_3/i.test(ua);
  
  var isAndroid = navigator.userAgent.match(/Android/i) !=null;
  var isAndroid = /Android/i.test(ua);
  
  var isiPhone = navigator.userAgent.match(/iPhone/i) !=null;
  var isiPhone = /iPhone/i.test(ua);
  
  if(isiPad) {
  alert("hello ipad!");
  } else if(isAndroid) {
  alert("hello android!");
  } else if(isiPhone) {
  alert("hello iphone!");
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Any idea what I'm doing wrong with the meta tag code?</p>