Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The correct properties are <code>offsetHeight</code> (not heightOffset) and <code>offsetWidth</code> (not widthOffset).<br> Those properties should correctly return the sizes you're after, because the children would expand the elements to fit, assuming overflow is set to visible. There's no need to calculate the sizes of the children in any situation.</p> <p><code>offsetHeight</code> and <code>offsetWidth</code> aren't part of any standard but most browsers seem to have them implemented anyway.</p> <p>Since you're having problems with Safari and offsetHeight, maybe you could try the <code>getClientRects()</code> method:</p> <p><a href="http://www.quirksmode.org/dom/tests/rectangles.html" rel="nofollow noreferrer">http://www.quirksmode.org/dom/tests/rectangles.html</a></p> <pre><code>var dims = links[i].getClientRects()[0]; var width = dims.right - dims.left; var height = dims.bottom - dims.top; </code></pre> <p>Can't say I've ever used <code>getClientRects()</code>, however. It sounds like the results may be closer to clientWidth and clientHeight.</p> <p><strong>FURTHER EDIT</strong><br> I figured out a workaround. The following does not work:</p> <pre><code>&lt;a href="#"&gt; &lt;img onclick="press(event);" src="http://sstatic.net/so/img/logo.png" alt="" /&gt; &lt;!-- onclick handler alerts with size 250x15 --&gt; &lt;/a&gt; </code></pre> <p>But wrapping a <code>&lt;span&gt;</code> tag around the <code>&lt;img&gt;</code> tag, like so:</p> <pre><code>&lt;a href="#"&gt;&lt;span&gt; &lt;img onclick="press(event);" src="http://sstatic.net/so/img/logo.png" /&gt; &lt;!-- onclick handler alerts with size 250x61 --&gt; &lt;/span&gt;&lt;/a&gt; </code></pre> <p>Fixes the problem. At least, it does in Chrome but like I said before Chrome and Safari share the WebKit rendering engine, so it should work for Safari too. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload