SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    Under Construction Poop_Shoot's Avatar
    Join Date
    Jul 2003
    Location
    Sacramento, CA
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Returning Width of Any element?

    Is it possidble to return the width of any element! Say a table Cell Or Div! Basically returning the space available to that element?

  2. #2
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In IE, the .clientWidth property of an element in the DOM should give you what you want. Dunno about other browsers though.
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  3. #3
    Under Construction Poop_Shoot's Avatar
    Join Date
    Jul 2003
    Location
    Sacramento, CA
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are other browsers than IE!! JK! Thanx

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    northern Maine
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .offsetWidth

    Or, the correct DOM2 CSS way (only Moz supports this):

    // elRef is a reference to the element
    document.defaultView.getComputedStyle(elRef, "").getPropertyValue("width");
    Jason - Contact Me
    Supermoderator @ CodingForums

  5. #5
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Cali
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jkd
    .offsetWidth

    Or, the correct DOM2 CSS way (only Moz supports this):

    // elRef is a reference to the element
    document.defaultView.getComputedStyle(elRef, "").getPropertyValue("width");

    I use .offsetTop and that seems to work in IE6 and mozilla

  6. #6
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DJ_Java
    I use .offsetTop and that seems to work in IE6 and mozilla
    You use offsetTop to retrieve the width of an element?

    That's some trick you've got there
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •