Note that there are some explanatory texts on larger screens.

plurals
  1. POcomputing $(this).css(”width”) _correctly_ in Safari
    text
    copied!<p>Asked <a href="https://stackoverflow.com/questions/1374914/this-csswidth-not-working-on-anchor-tags-in-safari">this</a> question earlier today, but I think I awarded a correct answer too early. I'm trying to figure out how to grab the css length and width of an anchor element with jquery in Safari. But I keep getting "0" returned, and I was told that this was because the javascript is firing before the css is rendered - a quirk of Webkit browsers.</p> <p>Here is the original page: <a href="http://f1shw1ck.com/jquery_sandbox/csspops-orig.html" rel="nofollow noreferrer">http://f1shw1ck.com/jquery_sandbox/csspops-orig.html</a></p> <p>However, I wrote a little test, telling jquery to wait until everything is completely rendered before grabbing the css. <a href="http://f1shw1ck.com/jquery_sandbox/csspops.html" rel="nofollow noreferrer">http://f1shw1ck.com/jquery_sandbox/csspops.html</a></p> <p>For selector </p> <pre><code>a.popup { width: 800px; height: 560px; } </code></pre> <p>and html </p> <pre><code>&lt;a href="http://www.metmuseum.org/toah/hd/apol/hd_apol.htm" class="popup"&gt;African Rock Art: Apollo 11 Cave Stone (c. 25,500 - 23,500 BCE); Wonderwerk Cave Stones (c. 8000 BCE)&lt;/a&gt; </code></pre> <p>wait until the page is completely, then get those dimensions:</p> <pre><code>$(document).ready(function () { if (jQuery.browser.safari &amp;&amp; document.readyState != "complete"){ //console.info('ready...'); setTimeout( arguments.callee, 5000 ); return; } alert($("a.popup").css("width")); }); </code></pre> <p>Except "0" is still getting returned in Safari. Am I going about this the wrong way, or is there some other cause at play?</p> <p>Thanks!</p>
 

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