Loading ...
Sorry, an error occurred while loading the content.

Re: YAHOO.util.Dom.getRegion() - Need values relative to container

Expand Messages
  • viruschidai
    Bad code. I should call Dom.get(divID) only once. :)
    Message 1 of 6 , Aug 27, 2009
    • 0 Attachment
      Bad code. I should call Dom.get(divID) only once. :)


      --- In ydn-javascript@yahoogroups.com, "viruschidai" <viruschidai@...> wrote:
      >
      > I had a try in IE 6, it seems Dom.getStyle(divID,'left') returns auto when position is not specified.
      >
      > try to use:
      > var Dom = YAHOO.util.Dom;
      > Dom.get(divID).offsetLeft;
      > Dom.get(divID).offsetTop;
      > Dom.get(divID).offsetWidth;
      > Dom.get(divID).offsetHeight;
      >
      > regards,
      > Bill
      >
      >
      >
      > --- In ydn-javascript@yahoogroups.com, Adam Moore <adamoore@> wrote:
      > >
      > > On Fri, Aug 28, 2009 at 12:56:29AM -0000, vaxace wrote:
      > > > Unfortunately, getStyle() for dimensions is not reliable.
      > > > If the current dimension was set automatically, the return value will
      > > > return 'auto', not the actual size.
      > > >
      > > > That's why I'm using getRegion()
      > >
      > > The previous post was correct for getting the top and left values of
      > > your element, except you also need to use parseInt to get rid of the
      > > unit. If you need width and height, use the offsetWidth and
      > > offsetHeight properties of the element instead of the style properties.
      > >
      > > -Adam
      > >
      > > >
      > > > Thanks,
      > > >
      > > > D.
      > > >
      > > > --- In ydn-javascript@yahoogroups.com, "viruschidai" <viruschidai@> wrote:
      > > > >
      > > > > Hi,
      > > > >
      > > > > Try the following code:
      > > > > var Dom = YAHOO.util.Dom;
      > > > > Dom.getStyle(divID,'left');
      > > > > Dom.getStyle(divID,'top');
      > > > >
      > > > > regards,
      > > > > Bill
      > > > >
      > > > > --- In ydn-javascript@yahoogroups.com, "vaxace" <dmp-yahoo@> wrote:
      > > > > >
      > > > > > I have an absolutely positioned <div> inside a relatively positioned <div>.
      > > > > >
      > > > > > When I call getRegion(), it returns the values relative to the view port, not the containing <div>.
      > > > > >
      > > > > > Is there any reliable way to get the region values relative to the container?
      > > > > >
      > > > > > Thanks,
      > > > > > D.
      > > > > >
      > > > >
      > > >
      > > >
      > > >
      > > >
      > > > ------------------------------------
      > > >
      > > > Yahoo! Groups Links
      > > >
      > > >
      > > >
      > >
      > > --
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.