www.webdeveloper.com
Results 1 to 10 of 10

Thread: reset Height to nothing

  1. #1
    Join Date
    Oct 2006
    Location
    Ontario Canada
    Posts
    1,160

    reset Height to nothing

    Hello,

    I hit a small bump in my code.

    How can I reset a height property back to nothing ?

    if my div was..
    Code:
    <div id="test" stye="height:550px; border:1px solid #000;"> some text 550 px long...</div>
    I tryied setting .height = "";
    But its not working in IE6

    Any ideas ?

    Drew
    Last edited by cgishack; 02-18-2008 at 10:35 AM.

  2. #2
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    your missing a closing quote on that ID :P

    PHP Code:
    document.getElementById("test").style.height '0px'
    ?

    edit: quote not bracket. silly me.
    If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
    The same applies to HTML and the forums [HTML][/HTML] tags.

  3. #3
    Join Date
    Oct 2006
    Location
    Ontario Canada
    Posts
    1,160
    Ahh.. sorry. That was me just typing the example. The code had the correct syntax.

    I think I solved my problem though.

    element.height =""; does reset the div to nothing....

    It may have been just a browser cache issue.

    Thanks for the reply though.

    Drew

  4. #4
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,773

  5. #5
    Join Date
    Oct 2006
    Location
    Ontario Canada
    Posts
    1,160
    Doh!

    true.. i think it was just one of those days..

    Thanks!

    Drew

  6. #6
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    You can also reset the height to null
    Code:
    document.getElementById("test").style.height = null;

  7. #7
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    not recomended because of the way some less common browsers handle that(turning null into a string 'null' before assigning it).
    If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
    The same applies to HTML and the forums [HTML][/HTML] tags.

  8. #8
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by scragar
    not recomended because of the way some less common browsers handle that(turning null into a string 'null' before assigning it).
    Really? I would not have imagined that... I guess those browsers have a bug. Javascript should permit a null value in any kind of assignment... Which browsers? I am just curious.

  9. #9
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    I have never come across it myself, it was documented somewhere(although I cannot find it any more)...
    If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
    The same applies to HTML and the forums [HTML][/HTML] tags.

  10. #10
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    ok, never mind... Anyway, you are right. A stringed value should be safer in that case. I was just remembered the null possibility...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles