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 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2006
    Location
    GB
    Posts
    79
    Thanks
    3
    Thanked 1 Time in 1 Post

    Resizing according to screen dimensions

    I've made a script to resize certain elements of my page according to how much of the window is available.

    It uses absolute positioning.

    PHP Code:
    function resize(){
        var 
    height=document.documentElement.clientHeight;
        var 
    width=document.documentElement.clientWidth;

        
    document.getElementById('spare').style.height=(height-32)+"px";
        
    document.getElementById('spare').style.width=(width-767)+"px";

    I'm getting this error.

    Code:
    document.getElementById("spare") has no properties
    .../script.js
    Line 26
    The element is an iframe, and if needed I can provide more code, but in the meantime, I'm getting some kip!

    Thanks for reading this thread, farewell.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Does the iframe have an id of "spare"?

  • #3
    New Coder
    Join Date
    Dec 2006
    Location
    GB
    Posts
    79
    Thanks
    3
    Thanked 1 Time in 1 Post
    Yes.

    PHP Code:
    <iframe src="blank.html" id="spare" frameborder="0" style="position:absolute; bottom:0px; right:0px;"></iframe

  • #4
    New Coder
    Join Date
    Dec 2006
    Location
    GB
    Posts
    79
    Thanks
    3
    Thanked 1 Time in 1 Post
    The element does exist once the page has loaded, so I think that when resize(); is called onload, the iframe hasn't been created yet, so has no properties.

    Would this me likely?


  •  

    Posting Permissions

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