I think it is a bug with offsetWidth, it should not be 50 but the
computed width instead.

Erik Arvidsson wrote:
> 
> I'm sorry for the need to keep asking questions in this forum. Is there any
> better way to find answers about Mozilla?
> 
> The problem I'm having is that I need to get the size of the text inside an
> element. The thing is that offsetWidth/Height does not include the part that
> is placed outside the size... pretty hard to explain. See the code below
> and/or try out the attached file.
> 
> erik arvidsson
> 
> the overflow should be hidden but it is easier to see the problem with
> overflow: visible;
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>  "http://www.w3.org/TR/html4/loose.dtd">
> 
> <html>
> <head>
> 
> <title></title>
> <style type="text/css">
> 
> #t {
>  position: absolute;
>  XXXoverflow: hidden;
>  background: blue;
>  width:  100px;
>  height:  100px;
> }
> 
> #t2 {
>  position: absolute;
>  background: yellow;
>  height:  50px;
>  left:  50px;
>  top:  25px;
>  white-space: nowrap;
> }
> 
> </style>
> <script type="text/javascript">
> 
> function inspect(obj) {
>  var str = "";
>  for (var prop in obj)
>   str += "obj." + prop + " = " + obj[prop] + "\n"
>  alert(str);
> }
> 
> function testIt() {
>  var t2 = document.getElementById("t2");
>  inspect(t2);
> }
> 
> </script>
> </head>
> <body>
> 
> <div id="t">
>  <div id="t2">
>   No wrap. No wrap. No wrap. No wrap.
>  </div>
> </div>
> <br>
> <br>
> <br>
> <br>
> <br>
> <br>
> <br>
> <br>
> <br>
> <br>
> <br>
> <br>
> <button onclick="testIt()">Test it</button>
> 
> </body>
> </html>
> 
> No wrap. No wrap. No wrap. No wrap.
> 
> Test it

-- 
        
        Martin Honnen
        http://javascript.faqts.com/
        http://home.t-online.de/home/martin.honnen/jsgoddies.html

Reply via email to