Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    377
    Thanks
    8
    Thanked 1 Time in 1 Post

    Change image size with DOM

    Hello,

    I have following image on my page, I use it as a spacer gif to get correct columns sizes.
    Code:
    <img id="leftcolumnspacer" src="images/spacer.gif" alt="">
    I also enable the admin to preview the site in an iframe and change size of for exp. left column. Playing with td sizes do not give me exact pixel sizes, so I would like to make sure that a td is displayed correctly, by resizing the spacer gif.


    Code:
    var LeftColumnSpacerWidth = myForm.leftcolumnspacer_width.value; // comes from the form
    var leftcolumnspacer = frames['testsite'].document.getElementById('leftcolumnspacer');
    leftcolumspacer.style.width = LeftColumnSpacerWidth;
    Why would this code not change the sizes of an image dynamically?

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by guvenck View Post
    …spacer gif…
    :shudder:

    Wake up and smell the 21st Century.

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Posts
    377
    Thanks
    8
    Thanked 1 Time in 1 Post
    If you are using tables, than there is no other effective way than spacer gifs that guarantees exact table cell widths on several browsers.

  • #4
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Why would you need pixel perfect sizing for a table cell?


    <on-topic>

    I suspect that LeftColumnSpacerWidth is a number and you're forgetting to add the unit.

    e.g.
    Code:
    leftcolumspacer.style.width = LeftColumnSpacerWidth+'px';
    </on-topic>

    No offense meant, but from what I can tell, you seem to be going about things in a particularly sub-optimal way.

  • #5
    Regular Coder
    Join Date
    Jan 2006
    Posts
    377
    Thanks
    8
    Thanked 1 Time in 1 Post
    I write a website-maker for people with absolutely no webmastering abilities. In their admin panel, I give them options (in this case left column width) and a preview of their actual site in an iframe. Depending on the options, I change the site in the iframe dynamically. If they like it, they save the style.

    The site has a leftcolumn, a middle one and a right one. I give them options to disable the left one, the right one, or both. So, for me, that means: middle column td = 100%.

    Left and right column tds are in pixels.

    The problem is, the content in the middle column is dynamic and because its width is set to 100%, it forces one of the columns (mostly right one) that right column becomes narrower than it's should-have width. The only way that I know is to place spacer gifs inside the column and "lock" it at a certain size. That's why.

  • #6
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    I'll put it another way - why use tables for layouts at all?

    By offering an 'easy builder' which generates layouts using tables (incl. spacer gifs), imho, you're demonstrating that your own webmastering abilities aren't perhaps what they should be for such a venture.

    There is plenty of info available online informing readers why using tables for layout is a bad idea (and how web development is trying to move out of that phase.
    e.g. http://www.hotdesign.com/seybold/

    It might be an idea for you to update your own skills to encompass creating layouts using semantic markup, css and a minimal number of divs before you empower users to start pumping out numerous more sites using potentially (read: quite probably) problematic and out-dated techniques.

    As said, no offense meant, but I am concerned that your well-meant efforts will serve to contribute more to the problems of current web design, than to their solution.
    Last edited by Bill Posters; 07-09-2007 at 05:48 PM.

  • #7
    Regular Coder
    Join Date
    Jan 2006
    Posts
    377
    Thanks
    8
    Thanked 1 Time in 1 Post
    Hi, thanks for the answer. I am pretty aware of where the web design is moving. I know the disadvantages of using tables. But I also know that CSS is not there where it is expected to be. To me, CSS is a big mess because of the browser incompatibilities and believe me, I dived a long time ago into the world of table-less designs (A List Apart, Zen Garden etc...) and it wasn't a good experience for me.

    I wouldn't have decided to go with tables if the alternative (CSS and Divs) would be standing rock solid in front of me. But unfortunately it does not and although I agree completely with what you are saying, I prefer the "good old tables" way.

  • #8
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    There are plenty of CSS-based sites which perform solidly x-browser.
    CSS is no longer the next generation technology waiting to break through. It's here and it works.
    If there were teething troubles, knowledgable designers and developers wouldn't be using it.

    If you're having substantial problems then it's down to one of two things: either you're trying to support very old browsers or, as mentioned, your CSS skills aren't perhaps up to what they should be.

    I honestly don't say these things to offend, but I do think that it's time that you took another look around at the many resources available to guide and help in building solid, CSS-based layouts.
    Last edited by Bill Posters; 07-09-2007 at 08:08 PM.

  • #9
    Regular Coder
    Join Date
    Jan 2006
    Posts
    377
    Thanks
    8
    Thanked 1 Time in 1 Post
    Ok, ok no offense taken

    What if I show you a demo of what I've done and maybe you can tell me if it can be done with CSS only?

  • #10
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    That's a good idea.
    However, it's probably best to open it up for comments and help in a new thread.

    Remember to post a link.




    On a side note, are you aware that the domain in your signature appears to have expired three weeks ago?

  • #11
    Regular Coder
    Join Date
    Jan 2006
    Posts
    377
    Thanks
    8
    Thanked 1 Time in 1 Post
    Hmm, I can't decide which forum to post it on CSS, or JS?

    Signature, yes, you are right, I transferred it to another registrar, forgot to set the new nameservers.

  • #12
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    It's definately a markup and CSS question, a structure and layout question, so should go in the HTML & CSS section.
    I'm not suggesting you post the same query again, but start a new thread asking for advice and help converting a tables-based layout to a CSS-based layout.

    There may be some js questions later, as you reintroduce the user functionality for your service, but it's best to get the basics sorted first.


  •  

    Posting Permissions

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