Results 1 to 6 of 6

Thread: Javascript Help

  1. #1
    Join Date
    Aug 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Javascript Help

    I recently found a need to have a Javascript auto detect the page height, and width of my iframe i was using on my website.

    Code:
    <script>
    document.write('<iframe width="'+(window.innerWidth?window.innerWidth:document.body.clientWidth)+'" height="'+(window.innerHeight?window.innerHeight:document.body.clientHeight)+'" src="report.cfm" name="content"></iframe>');
    </script>
    Is the code I am using, and it works extremely well, however the problem is not only do i need the script to auto-detect the page height, and width, but i need it to only do so to fill up the remaing space, NOT taken up by the navagation at the top. ie, if the Page Display is 1024x768 then i need the iframe to be 900x768

    Anyone see where I can improve my code to not only auto detect the window size, but also factor in that it needs to be 124 pixels smaller than the max window height?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I don't understand why you need to do this, and can't just use
    Code:
    style="height:100%;width:100%;"
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Aug 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    <DIV id=content style="Z-INDEX: 1; LEFT: 0px; RIGHT: 0px; WIDTH: 1013px; POSITION: absolute; TOP: 69px; HEIGHT: 546px">
    	
    	
    <script>
    document.write('<iframe width="'+(window.innerWidth?window.innerWidth:document.body.clientWidth)+'" height="'+(window.innerHeight?window.innerHeight:document.body.clientHeight)+'" src="report.cfm" name="content"></iframe>');
    </script>
    
    <!---
    <IFRAME src="report.cfm" frameBorder=0 width=100% height=100% name="content">
    --->
    </DIV>
    because i am using it in the following notation.

    so to clarify, the DIV is forcing the page to load with those dimentions, ie atleast, 1013px and drop the location of the ifram down 69px from the top so that there is room for the navagation, then i need the iframe to auto ditecto the size of the browser being used, and fix itself to take up the room down below, minus the room at the top [the 69px]

    using the 100% by 100% om the origional iframe code [commented out above] only limited it to that as defined in the div
    Last edited by skilled1; 04-03-2006 at 06:07 PM.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Using absolute pixel values for everything is a very bad idea. I suggest you rethink your layout using percentage or em values
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Aug 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i understand that it is a bad idea, but that is not the fixthat i am currently looking for, i just need help with the code to do exactly what it is already doing - the 69pixels from the top to leave way for the navigation [or rather not add the 69pixels to the bottom of the page making it scroll for no reason]

  6. #6
    Join Date
    Aug 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ahhhh i figured it out with help from another forum

    Code:
    <script>
    document.write('<iframe width="'+((window.innerWidth?window.innerWidth:document.body.clientWidth) -0) +'" height="'+((window.innerHeight?window.innerHeight:document.body.clientHeight) - 69) +'" src="report.cfm" name="content"></iframe>');
    </script>
    if anyone wants the code please feel free to use it

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
  •