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.
Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 50
  1. #16
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Post a link to your site.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  2. #17
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help

    http://www.promoclubmexico.com/mexic...taro/index.php

    Just need the code to work on Firefox because the code works perfectly on IE, but its not jet published (the ie code). So thanks if you can help me out whit a code for firefox, because i just found a lot of codes all for IE.

    Thanks

  3. #18
    New to the CF scene
    Join Date
    May 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Trick to resize iframe if new page are shorter than previous (works FF and IE)

    Hello, for a long time I was looking for "resize iframe" and fix bugs when new page are shorter than the previous.

    I know that is not an elegant way to do it, but it works, if someone else knows how to do it better, please show me.

    *** CODE - parent page ***
    <head>
    ...
    <script>
    function change_height() {
    if(document.getElementById && !(document.all)) {
    height = "1px";
    document.getElementById(framename).style.height = height;
    height = document.getElementById(framename).contentDocument.body.scrollHeight;
    document.getElementById(framename).style.height = height;
    }
    else if(document.all) {
    height = "1px";
    document.all.framename.style.height = height;
    height = document.frames(framename).document.body.scrollHeight;
    document.all.framename.style.height = height;
    }
    }
    <script>

    ...

    </head>
    <body>
    ...
    <iframe onload="change_height()" src="iframepage.htm" style="width:100%;" name="framename" frameborder="no" scrolling="no" marginwidth="0" marginheight="0" id="framename"></iframe>
    ...
    </body>
    ...


    **** CODE ****

    see you guys....

  4. #19
    New Coder
    Join Date
    Nov 2006
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I just want the iFrame to resize based on it's content

    I used Anthony's code:

    <script type="text/javascript">

    function setIframeHeight(energysaver) {
    var iframeWin = window.frames[energysaver];
    var iframeEl = document.getElementById? document.getElementById(energysaver): document.all? document.all[energysaver]: null;
    if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
    //var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    iframeEl.style.height = 100 + "%";
    alert(document.height);
    }
    }
    </script>

    <body onload="setIframeHeight('ifrm');">

    <iframe name="energysaver" id="energysaver" frameborder="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" width="800" height="100%" src="http://www.energyguide.com/redirect.asp?referrerid=236&sid=461" scrolling="no" style="overflow:visible"></iframe>

    And I am having no luck...any suggestions?

  5. #20
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    using code from anthony b, looks good so far, works ok , except in IE6. If I load some page of wiki, the vertical scroll bar dissapears in a split of second, and I cant scroll. if I load forinstance this page(cooding f.), or some of my contence, it is ok. In FF, no problem eitherway.

    Edit: IE7 same as IE6.


    Anyone knows what would be the reason ?
    Last edited by BubikolRamios; 10-13-2008 at 04:32 AM.

  6. #21
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    the answer to this is:
    change
    scroll = 'yes'
    to
    scroll = 'auto'

    and now it is ok on FF and IE

  7. #22
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by monclee View Post
    (ashamed) Sorry really but Im eating thanks to my page. I havent sleep. Im sorry I never meant to be a fool on java. Im trying to learn.

    BUT I DID IT¡¡¡¡¡ I just need this code work on Firefox thanks. I wont post anymore.

    well heres the code i found whats wrong?¡¡¡¡

    <script type="text/javascript">

    /***********************************************
    * IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
    * Visit DynamicDrive.com for hundreds of original DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/

    //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
    //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
    var iframeids=["main"]

    //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
    var iframehide="yes"

    var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
    var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

    function resizeCaller() {
    var dyniframe=new Array()
    for (i=0; i<iframeids.length; i++){
    if (document.getElementById)
    resizeIframe(iframeids[i])
    //reveal iframe for lower end browsers? (see var above):
    if ((document.all || document.getElementById) && iframehide=="no"){
    var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
    tempobj.style.display="block"
    }
    }
    }

    function resizeIframe(frameid){
    var currentfr=document.getElementById(frameid)
    if (currentfr && !window.opera){
    currentfr.style.display="block"
    if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
    currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
    else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
    currentfr.height = currentfr.Document.body.scrollHeight;
    if (currentfr.addEventListener)
    currentfr.addEventListener("load", readjustIframe, false)
    else if (currentfr.attachEvent){
    currentfr.detachEvent("onload", readjustIframe) // Bug fix line
    currentfr.attachEvent("onload", readjustIframe)
    }
    }
    }

    function readjustIframe(loadevt) {
    var crossevt=(window.event)? event : loadevt
    var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
    if (iframeroot)
    resizeIframe(iframeroot.id);
    }

    function loadintoIframe(iframeid, url){
    if (document.getElementById)
    document.getElementById(iframeid).src=url
    }

    if (window.addEventListener)
    window.addEventListener("load", resizeCaller, false)
    else if (window.attachEvent)
    window.attachEvent("onload", resizeCaller)
    else
    window.onload=resizeCaller

    </script>

    </head>

    <iframe id="main" name="main" src="Bienvenido.html" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:697px ; display:none"></iframe>
    Hi Guys, This script works well when you link a page within the same domain, but as soon as I link to a page from a different domain, I can this error:

    Permission denied to get property HTMLDocument.body
    [error] if (currentfr.contentDocument && current...Document.body.offsetHeight) //ns6 syntax

    How can I solve this problem?

  8. #23
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any ideas please?

  9. #24
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up auto resize iframe height

    Hi everyone,

    The below code might help you.
    It works well in both Firefox and IE all versions.

    Code:


    function setIframeHeight(iframeName) {
    var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
    if (iframeEl) {
    iframeEl.style.height = "auto";
    // need to add to height to be sure it will all show
    var h = alertSize(iframeName);
    iframeEl.style.height =h + "px";
    }
    }

    function alertSize(frameId) {
    var myHeight = 0;
    frame = document.getElementById(frameId);
    if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
    var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0;
    myHeight=frame.contentDocument.body.offsetHeight+FFextraHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'

    innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
    myHeight= innerDoc.body.scrollHeight + 10;
    //myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
    }
    //window.alert( 'Height = ' + myHeight );
    return myHeight;
    }



    Iframe tag:

    <iframe id="boardframe" scrolling="auto" name="boardiframe" width="600" frameborder="0" src="http://yourdomain.com/Comments.aspx?id=xxx" onload="setIframeHeight('boardframe');"></iframe>


    Cheers
    Sunil
    Last edited by sunilrajkg; 05-22-2009 at 09:36 AM.

  10. #25
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    see the reply and tell me if it was helpful for u...

  11. #26
    G__
    G__ is offline
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

    Question

    Hi,

    So far this is the only script that works for IE and Safari. I can't get it to fully work with Firefox. It does not fully expand the iFrame when needed like IE.
    Sorry I can't post the site yet. I am working on this locally.
    Anything need to be tweaked for Firefox 3.0.11 for the below script?
    Thanks to all for the posts and help.
    G.

    This is the code I am using at this time:
    Code:
    <script type="text/javascript">
    function setIframeHeight(iframeName) {
    var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
    if (iframeEl) {
    iframeEl.style.height = "auto";
    // need to add to height to be sure it will all show
    var h = alertSize(iframeName);
    iframeEl.style.height =h + "px";
    }
    }
    
    function alertSize(frameId) {
    var myHeight = 0;
    frame = document.getElementById(frameId);
    if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
    var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0;
    myHeight=frame.contentDocument.body.offsetHeight+FFextraHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    
    innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
    myHeight= innerDoc.body.scrollHeight + 10;
    //myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
    }
    //window.alert( 'Height = ' + myHeight );
    return myHeight;
    }
    
    </script>
    
    
    <iframe id="boardframe" scrolling="auto" class="iframe_main"  name="main" src="main.htm" frameborder="0" marginheight="0" marginwidth="0" allowtransparency="yes" onload="setIframeHeight('boardframe');">
    </iframe>

  12. #27
    G__
    G__ is offline
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post
    Hello again,

    I think I figured it out for FireFox 3.0.xx.
    I changed the value of 16 in the red line to 70. I'm guessing that is the extra line length added to the iFrame for FireFox? If I'm wrong, Please post the proper tweak to the code.

    Thanks again.

    Code:
    //Non-IE
    var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
    
    var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0;
    
    myHeight=frame.contentDocument.body.offsetHeight+FFextraHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    dth || document.documentElement.clientHeight ) ) {

  13. Users who have thanked G__ for this post:

    cincinnatiboy4867 (07-21-2009)

  14. #28
    Regular Coder
    Join Date
    Nov 2008
    Posts
    317
    Thanks
    159
    Thanked 0 Times in 0 Posts
    I'm trying to change the height automatically with iframes as well and I can't seem to get any of the scripts to work on this page:

    http://www. durkmusicbeats . com/beats.html

    Does anybody know why?
    durkmusicbeats . com

  15. #29
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cross-site auto-resize Iframes


  16. #30
    Regular Coder
    Join Date
    Apr 2006
    Posts
    128
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I tried this code. It doesn't work. The content of the iframe is coming from a different page. I include a form with the iframe. When the form submits I need the iframe section resized. But it doesn't. Is there a way to do that vwphilips?

    Quote Originally Posted by vwphillips View Post
    Code:
    <body onload="setIframeHeight('ifrm');" onresize="setIframeHeight('ifrm');">


 
Page 2 of 4 FirstFirst 1234 LastLast

Posting Permissions

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