SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    weird behaviour with scrollWidth property

    I'm trying to use IE expressions within a CSS file to simulate the unsupported min-width property

    To do the same for min-height, the following works fine

    Code:
    height: expression( this.scrollHeight < 300 ? "300px" : "auto");
    I would think that this should work fine as well, but it doesn't

    Code:
    	width: expression( this.scrollWidth < 300 ? "300px" : "auto" );
    Instead, it freezes the browser and sends the CPU usage through the roof as if there was an infinite loop defined.

    To troubleshoot, I tried this:

    Code:
    	width: expression(alert(this.scrollWidth));
    I would expect that a value would be alerted once. Instead, it alerts twice when the page loads and then 2 more times every time I move my mouse over the element I'm applying this style to.

    Any idea why scrollWidth seems to be evaluated over and over where scrollHeight does not?

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi daveh0,

    I played with this some, used different properties and conditions - I don't have an answer but I do see what you ran into. The width gets set to '300px' then 'auto' then repeats this over and over, because auto results in width < 300. I tried "<=" and even considered padding and border effects on width. I did get it to not 'hang' - but I did not come up with a real 'min-width'.

    While browsing for info I came across this good post by Tommy. Using expression can cause printing problems - check that out.

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CSS expressions are evil, try this instead.


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
  •