SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting the dynamic width of a div

    I'm using
    Code:
    var w = document.getElementById('center').offsetWidth;
    to get the width of a div in my liquid css layout. I want to use the variable "w" to resize an image in my content based on teh width of div "center". Although the offsetWidth variable doesn't seem to have many fans, its the best I can seem to find, and it works in FF and IE, but is there a better method to get the width of this? I don't set the width of this div, this gets set dynamically with css based on the width of the browser window.

    Also, what code do I need to do, to re-run this code upon the resizing of the browser window? I can't seem to find the right command or code to do this. Isn't there a onWindowResize behavior or something? I'm a NOOB to JS, just an FYI.
    Not another drugstore, not another town
    Tired of the overdrop, I had to put it down
    You know I was the man when I put the Crown down
    Then rolled around the Chemicals to pave the New Sound

  2. #2
    SitePoint Addict trigger's Avatar
    Join Date
    Jun 2003
    Location
    Eagan
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is
    Code:
    <body onResize="document.location.href = document.location.href">
    the best solution for my re-running the .js when the window gets resized? I want to use "best practices".
    Not another drugstore, not another town
    Tired of the overdrop, I had to put it down
    You know I was the man when I put the Crown down
    Then rolled around the Chemicals to pave the New Sound


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
  •