1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

iframe height

Discussion in 'HTML & Website Design' started by fgsg, Feb 5, 2011.

  1. #1
    hi,

    i have verry big problem so i add on my page iframe1 for iframe1 height is 2000px; for iframe2 height is 500px; and now i have problem, how make automatic height for my page because if i add height 3000px; then is to much for iframe2 i need some way how add automatic ? Thanks.
     
    fgsg, Feb 5, 2011 IP
  2. thewantedhost

    thewantedhost Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try height: auto; ?
     
    thewantedhost, Feb 5, 2011 IP
  3. fgsg

    fgsg Well-Known Member

    Messages:
    275
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    i was dont work
     
    fgsg, Feb 5, 2011 IP
  4. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
  5. clonepal

    clonepal Active Member

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    73
    #5
    Solution:

    
    <script type="text/javascript">
    		function setIframeHeight(iframeName) {
    		  //var iframeWin = window.frames[iframeName];
    		  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
    		  if (iframeEl) {
    		  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
    		  var h = alertSize();
    		  var new_h = (h-148);
    		  iframeEl.style.height = new_h + "px";
    		  //alertSize();
    		  }
    		}
    
    		function alertSize() {
    		  var myHeight = 0;
    		  if( typeof( window.innerWidth ) == 'number' ) {
    		    //Non-IE
    		    myHeight = window.innerHeight;
    		  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    		    //IE 6+ in 'standards compliant mode'
    		    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>
    	
    </head>
    
    <body onload="setIframeHeight('ifrm');">
    
    Code (markup):
     
    clonepal, Feb 7, 2011 IP