Solved

Dynamically Resized IFrames  collapse expand javascript jquery

Posted on 2010-09-04
4
947 Views
Last Modified: 2012-05-10
i have page with 5 iframe when i click in the first page within the firts  iframe
it will open the 2nd frame butw with diferent data (file attached)

i don't want to scror the iframe to view the data i want java scrpt that can  expand the iframe hight to the current page hight (Dynamically Resized IFrames)

admin.zip
0
Comment
Question by:palserv
  • 3
4 Comments
 
LVL 6

Expert Comment

by:youssefomar
ID: 33603245
if you need the iframes to be resized according to the current page size, then you don't need a javascript to do so... just use the frameset, define height percentage for each frame, and list the frames inside it ... like this:

<html>
<frameset rows="20%,20%,20%,20%,20%">
  <frame id="leftFrame" src="f1.htm">
  <frame id="rightFrame" src="f2.htm">
  <frame id="rightFrame" src="f3.htm">
  <frame id="rightFrame" src="f4.htm">
  <frame id="rightFrame" src="f5.htm">
</frameset>
</html>

Open in new window

0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 33606145
Define this function in the admin.htm script section:

function setFrameSize(theFrame){
    var theDoc = top.frames[theFrame.name].document;
    theFrame.style.height = (Math.max(
        Math.max(theDoc.body.scrollHeight, theDoc.documentElement.scrollHeight),
        Math.max(theDoc.body.offsetHeight, theDoc.documentElement.offsetHeight),
        Math.max(theDoc.body.clientHeight, theDoc.documentElement.clientHeight)
    ))+'px';
}  

call that function like this for the IFRAMEs that you want to resize:
<IFRAME id=Cat1 style="WIDTH: 100%; HEIGHT: 300px" name=Cat1  onLoad="setFrameSize(this)" marginWidth=0
marginHeight=0 src="admin_files/addCat.htm" frameBorder=1></IFRAME>

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 33606162
The body height script I have taken from here:
http://james.padolsey.com/javascript/get-document-height-cross-browser/

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 33699242
You are welcome.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question