Solved

Dynamically Resized IFrames  collapse expand javascript jquery

Posted on 2010-09-04
4
930 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now