title: undefined TypeError only on iPhone -- JavaScript, HTML5 canvas_context.measureText
body: <p>I'm having an issue when running a webpage on iOS Safari.</p>
  <p>I am using the <a href="http://code.google.com/p/canvas-text/" rel="nofollow noreferrer">canvas-text library</a> to render text which works perfectly on the following:</p>
  <ul>
  <li>Ubuntu/Windows -- chrome, firefox</li>
  <li>Mac -- Safari</li>
  <li>Android -- default, firefox, opera,
  dolphin</li>
  </ul>
  <p>However, it does not work on <strong>iPhone</strong>.</p>
  <p>I enabled the javascript console on the iPhone and I get a few errors which read :</p>
  <blockquote>
  <p>Javascript: Error undefined</p>
  <p>TypeError: 'undefined' is not an object</p>
  </blockquote>
  <p>The console does not display line numbers, but by placing alert boxes throughout the code I was able to isolate where the problem occured. Here is the code which produces the error:</p>
  <pre><code>usedX = context.measureText(textUsername).width + context.measureText(textInput).width + paddingInput*2 + borderInput*2;
  </code></pre>
  <p>The problem exists within context.measureText. I know this because I have tried replacing the previous code with the following:</p>
  <pre><code>var usedX = context.measureText(&quot;why is this an error?&quot;);
  </code></pre>
  <p>and I still got the error on that line.</p>
  <p>I know for sure that context and measureText are defined because I have done:</p>
  <pre><code>alert(context.measureText);
  </code></pre>
  <p>which alerted:</p>
  <blockquote>
  <p>function measureText(){[native code]}</p>
  </blockquote>
  <p>As I said, the problem seems to be in measureText. I have Googled lot's and could not find a solution.</p>
  <p>I am a JavaScript noob, so I won't be all that surprised if there is a simple fix. But it seems all is well with the code, and this is a problem with iPhone's implementation of measureText.</p>