SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member Pirateking's Avatar
    Join Date
    Nov 2004
    Location
    South Africa
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I get the scrolling length of a Iframe?

    Anyone know how I can get the scrolling length of a Iframe?

    I've tried these options but they only return the size of the Iframe itself, not the scroll length

    PHP Code:
    //---------------
    function GetWidth() {
      var 
    myWidth 0;
      if( 
    typeofwindow.parent.productlistingFrame.innerWidth ) == 'number' ) {
        
    //Non-IE
        
    myWidth window.parent.productlistingFrame.innerWidth;
      } else if( 
    document.getElementById("productlistingFrame") && document.getElementById("productlistingFrame").clientWidth ) {
        
    //IE 6+ in 'standards compliant mode'
        
    myWidth document.getElementById("productlistingFrame").clientWidth;
      }
      return 
    myWidth;
    }
    //----------------- 
    any ideas?
    Last edited by Pirateking; Dec 5, 2007 at 02:41. Reason: code tags :P

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Try comparing document.body.clientwidth with document.body.offsetwidth of the document body in the iframe.

    If IE6 is in standards mode, you'll need to use document.documentElement instead. of document.body

  3. #3
    SitePoint Member Pirateking's Avatar
    Join Date
    Nov 2004
    Location
    South Africa
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the reply, unfortunatly all those are returning the width of the window and not the iframe.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Show us what you're working with

  5. #5
    SitePoint Member Pirateking's Avatar
    Join Date
    Nov 2004
    Location
    South Africa
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    k well I'n letting a Iframe scroll throught the products by itself, basiclly when it's done it's scrolls all the way back. When the user mousover the frame it stops scrolling and user has full control over the scroll bar.

    the problem i'm sitting with is that I'm struggling to return a value that returns the maximum size of the Iframe.

    I've found that window.parent.productlistingFrame.scrollMaxX; will return the Iframe called productlistingFrame Maxmimum width.
    I also found window.parent.productlistingFrame.pageXOffset; that will return the current posistion of the scrollbar.

    The only problem I have now is to find an IE equivilent of these two properties, seeing as these properties I found only work in Firefox.

    If you need my page code to help understand I'll clean it up and post it seeing as it's a bit messy at the moment from trying to find the correct way of doing this in IE

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Please feel free to post a url to a live example. It will be easy to find answers then.

  7. #7
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    standards mode is a nice way to find out new thnigs

  8. #8
    SitePoint Member Pirateking's Avatar
    Join Date
    Nov 2004
    Location
    South Africa
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the help, I ended up using pmw's code on the Iframe's page itself and passed the values to the parent page, a hell of a work around but got it to work perfectly in all browsers ... damn ie

  9. #9
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Welcome to the club. Your I Hate IE badge is in the post


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
  •