Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: despertly need help-getelement by id wont work

  1. #1
    Join Date
    Jan 2008
    Posts
    73
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default despertly need help-getelement by id wont work

    function getWindowHeight() {
    var windowHeight=0;
    if (typeof(window.innerHeight)=='number') {
    windowHeight=window.innerHeight;
    }
    else {
    if (document.documentElement&&
    document.documentElement.clientHeight) {
    windowHeight=
    document.documentElement.clientHeight;
    }
    else {
    if (document.body&&document.body.clientHeight) {
    windowHeight=document.body.clientHeight;
    }
    }
    }
    return windowHeight;
    }
    var t
    t=getWindowHeight(this)
    alert(t)
    x=(t-400)
    document.getElementById('row4r').style.padding-bottom=x+"px"

  2. #2
    Join Date
    Jul 2008
    Posts
    102
    Thanks
    36
    Thanked 6 Times in 6 Posts

    Default

    Code:
    document.getElementById('row4r').style.padding-bottom=x+"px"
    Is this the part that wont work?

  3. #3
    Join Date
    Jan 2008
    Posts
    73
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    exactly
    checked for case sensitivity and lots of things

  4. #4
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Most likely, the page isn't loaded when you are trying to run that function. I need to see the whole page to be sure. But, if I'm right then try this code and see what happens
    Code:
    function getWindowHeight() {
    var windowHeight=0;
    if (typeof(window.innerHeight)=='number') {
    windowHeight=window.innerHeight;
    }
    else {
    if (document.documentElement&&
    document.documentElement.clientHeight) {
    windowHeight=
    document.documentElement.clientHeight;
    }
    else {
    if (document.body&&document.body.clientHeight) {
    windowHeight=document.body.clientHeight;
    }
    }
    }
    return windowHeight;
    }
    window.onload = function(){
    var t
    t=getWindowHeight(this)
    alert(t)
    x=(t-400)
    document.getElementById('row4r').style.padding-bottom=x+"px"
    }
    Just a note for the future, it is much easier to help if you format your code when posting.

  5. #5
    Join Date
    Jan 2008
    Posts
    73
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    first of all thanks for helping.here is the full page-and it's not working

    http://www.stargatemedia.co.il/abou_tt%20(2).htm

    god its furstrating.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This will never work:

    Code:
    document.getElementById('row4r').style.padding-bottom=x+"px"
    It needs to be:

    Code:
    document.getElementById('row4r').style.paddingBottom=x+"px";
    And, as mentioned already, document.getElementById('row4r') must already exist before this is executed, onload would be a good time because in IE, even the other dimensions you seek may not be available until that time anyway.

    Another caveat, there must be only one element on the page with the row4r id.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. The Following User Says Thank You to jscheuer1 For This Useful Post:

    genia (07-21-2008)

  8. #7
    Join Date
    Jan 2008
    Posts
    73
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    man,thank you very very very very very very much

  9. #8
    Join Date
    Jul 2008
    Posts
    102
    Thanks
    36
    Thanked 6 Times in 6 Posts

    Default

    Hehe well spotted jscheuer1

    If they had there head screwed on when they named these DOM attributes they could have kept them the same for CSS and javascript then things like this would happed.

    Dal

  10. #9
    Join Date
    Jan 2008
    Posts
    73
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    exactly.
    tell me something..now the function getWindowHeight gives me the height of the browser?
    can i change it to give me the height of the viewing port? how?

    Code:
    document.getElementById("row4r").style.height=document.screen.availHeight-660+"px"
    not quiet working...
    thanks again guys for your help
    Last edited by genia; 07-21-2008 at 06:25 PM.

  11. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This generally works:

    Code:
    function set_row4r(){
    var iecompattest = function(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
    };
    
    var wh = window.innerHeight? window.innerHeight : iecompattest().clientHeight;
    
    document.getElementById("row4r").style.height = wh + 'px';
    };
    window.onload = set_row4r;
    If you have other onload events, it would need to be integrated with them in one of the various ways available for that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •