title: How can I determine the viewBox of any <svg> Element from JavaScript?
body: <p>I'd like to determine the viewBox of an  element (i.e. an SVGSVGElement) from a JavaScript function. Calling:</p>
  
  <pre><code>svgElement.getAttribute("viewBox")
  </code></pre>
  
  <p>works great when the viewBox is explicitly set on the element. But I cannot assume this will always be the case. For instance, I'd like my function to work on all of these  tags:</p>
  
  <pre><code>(400, 100) &lt;svg width=400 height=100&gt;&lt;/svg&gt;
  (400, 100) &lt;svg width="400px" height="100px"&gt;&lt;/svg&gt;
  (400, 100) &lt;svg style="width: 400px; height: 100px"&gt;&lt;/svg&gt;
  (100,  25) &lt;svg viewBox="0 0 100 25" style="width: 400px; height: 100px"&gt;&lt;/svg&gt;
  (100,  25) &lt;svg viewBox="0 0 100 25" width=400 height=100&gt;&lt;/svg&gt;
  </code></pre>
  
  <p>(The values in parens are what the function should return in each case). I'd like to be able to do this across all browsers which support SVG and at all zoom levels.</p>
  
  <p>Here's a JSFiddle with one (failed) attempt: <a href="http://jsfiddle.net/w4BTD/1/" rel="nofollow">http://jsfiddle.net/w4BTD/1/</a></p>