Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: [DHTML] iFrame SSI IV

  1. #21
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Give your iframes that you want excluded a class="exclude" attribute, and use this function sizeFrame in place of the existing one:

    Code:
    function sizeFrame(){
    if(document.getElementsByTagName('frameset').length||!document.getElementsByTagName('iframe').length)
    return;
    var frEls=document.getElementsByTagName('iframe'), s='scrollHeight',
    frObs=window.frames, o='offsetHeight', b='body', de='documentElement';
    for (var cs, hb, hd, d='document', i = frEls.length-1; i > -1; --i)
    if (!/exclude/.test(frEls[i].className)){
    if(frObs[i][d][b].style.overflow)
    cs=frObs[i][d][b].style.overflow;
    frObs[i][d][b].style.overflow='hidden';
    frEls[i].height=10;
    frEls[i].height=Math.max(frObs[i][d][b][o], Math.max(frObs[i][d][de][o],
    (hd=frObs[i][d][de][s]) != (hb=frObs[i][d][b][s])? Math.max(hd, hb):0))+
    (frEls[i].height==frEls[i].offsetHeight&&frEls[i].getAttribute('frameborder',0)!=='0'?4:0);
    frObs[i][d][b].style.overflow=typeof cs=='string'? cs : '';
    };
    if(!sizeFrame.setup){
    for (var i = frEls.length-1; i > -1; --i)
    if (!/exclude/.test(frEls[i].className))
    sizeFrame.loadup(frEls[i]);
    sizeFrame.setup=true;
    }};
    I´m sorry to wake up an old thread.

    First of, thank you so much for this script! I've tried bunch of scripts and this is the only one that works on all browsers!

    But since I don't know javascript I have one question.

    I wonder if it's possible to make this code the other way around, so that only iframes with class="include" are resized.

    Problem is that I have a chatbar (facebook look-a-like) that uses iframes. The chat windows don't expand correctly when I add this script to the site. I can't edit the code for the chatbar so I'm not able to add class="exclude" to the code.

    I only need to resize one iframe so I was wondering if it would be possible to make this script only target that one frame.

    Thank you.

  2. #22
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Here's a quick guess. Save a backup of your page before trying this, but here's how I'd approach it:

    Find all lines like this:
    if (!/exclude/.test(frEls[i].className)){

    I see two of them in the code you quoted above, and there might be more places.

    Then replace them with this:
    if (/include/.test(frEls[i].className)){

    Or similar logic. The ! symbol means "not", so just remove the ! then change "exclude" to "include", and that should, I hope, work for you.
    (In the case that you find "exclude" without !, then you might need to add one so it's !+include. I'm guessing you won't find that though.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. The Following User Says Thank You to djr33 For This Useful Post:

    HighContrast (12-31-2011)

  4. #23
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Works like charm

    Thank you djr33!

    Happy new year!

  5. #24
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    For an alternative to the iFrame SSI IV script, see THIS.
    ===
    Arie Molendijk.

  6. #25
    Join Date
    May 2012
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    This is still working to date but in IE9 it cuts the last line in half.
    How can I get it to show the complete line.

    Thanks

  7. #26
    Join Date
    Jun 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Could this be used in a wordpress site? I'm trying to get it running but without any luck. it seems to shrink the iframe to about 100 pixels every time.

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
  •