Forum: Ruby on Rails prototype getHeight safari

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ceee1f15591d1f61ac5bec1bc70d0062?d=identicon&s=25 Sébastien Gruhier (Guest)
on 2006-05-08 17:06
(Received via mailing list)
Hi

I have a weird bug with getHeight or getDimensions().hegiht
(prototype) only on safari
if I have a html file like this
<div id="test"></div>

and a embedded css

<style>
#test {
   width:100px;
   height:100px;
   float:left;
}
</style>

In Safari $('test').getHeight returns 100, fine but if the css
declaration #test.. is in a css file included by a <link
href="stylet.css" rel="stylesheet" type="text/css" ></link>
The height is 0!!

Is it something known, is there a workaround?
Thanks
Seb
2da252cc1d2fb3701126171831b50a65?d=identicon&s=25 Dave Coleman (pezdude)
on 2006-05-08 18:50
> In Safari $('test').getHeight returns 100, fine but if the css
> declaration #test.. is in a css file included by a <link
> href="stylet.css" rel="stylesheet" type="text/css" ></link>
> The height is 0!!

Since your height is defined in the css and not inline, it's not an page
attribute that your javascript can read.

if you did:

<div id="thething" style="height: 100px;">thing</div>

it would work. In this case you could do:

height = $('thething').getHeight;

This is not just a Safari issue.

Thx!
2da252cc1d2fb3701126171831b50a65?d=identicon&s=25 Dave Coleman (pezdude)
on 2006-05-08 19:04
> if you did:
>
> <div id="thething" style="height: 100px;">thing</div>
>
> it would work. In this case you could do:
>
> height = $('thething').getHeight;
>
> This is not just a Safari issue.
>
> Thx!

Hmmm. didn't actually know what getHeight did so I looked it up, that
function returns the offsetHeight of an element, not the height defined
by your css (thing.style.height).

you could do: $('thething').style.height; instead.

http://www.quirksmode.org/viewport/compatibility.html
This topic is locked and can not be replied to.