Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Resize Iframe

Posted on 2006-07-20
6
Medium Priority
?
935 Views
Last Modified: 2009-07-29
I want to resize the iframe depending on the the size of the document loaded
into to the iframe so that i can use IE to scroll
0
Comment
Question by:anand
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 17151960
Like this:

<IFRAME name="myiframe" onload="this.style.height=parseInt(window.frames.myiframe.document.body.scrollHeight)+50;" style="OVERFLOW: auto; WIDTH: 100%;height:100%;" src="joke.htm" frameBorder="1"></IFRAME>


0
 

Author Comment

by:anand
ID: 17152385
Thanks for u r reply,

i tried the code which u have mentioned above,
but, i dont want to use the iframe's scrolling bar instead i want to scroll using the IE 's scroll bar,how can i do that


thank u
anand


0
 
LVL 29

Assisted Solution

by:Pravin Asar
Pravin Asar earned 500 total points
ID: 17153085
Here is a another approach (uses iframe as buffer with auto-size of div tag).

To do this, you could have hidden iframe, and send the contents to div.
Here is an example. Only thing is the iframe page should be from your own domain.
For security purpose you can not read the external domain pages (other than yours).


 

<html>
<head>
<title>Using an Iframe as a Buffer</title>
<style type="text/css">
</style>
<script type="text/javascript">
function loadExternal(url) {
  if (window.frames['buffer'] ) {
    window.frames['buffer'].location = url;
    var lyr = document.getElementById? document.getElementById('MainDisplay'): document.all? document.all['MainDisplay']: null;
    if ( lyr && typeof lyr.innerHTML != "undefined" ) {
      lyr.innerHTML = '<img src="/images/loading.gif" alt="">';      
    }
    return false;
  }
  return true; // other browsers follow link
}

// called when documents loaded into iframe (from their body's onload attribute)
function displayExternal() {
  var lyr = document.getElementById? document.getElementById('MainDisplay'): document.all? document.all['MainDisplay']: null;
    if ( window.frames['buffer'] && lyr && typeof lyr.innerHTML != "undefined" ) {
      lyr.innerHTML = window.frames['buffer'].document.body.innerHTML;
    }
}
</script>
</head>
<body>
<h1>Welcome!</h1>
<p>This is an example, how we can have dynamically sized div (using IFRAME as a buffer).</p>
<p>NOTE: All page should be from current domain! to obtain the page properties.</p>
<style type="text/css">
TD { width: 200px;}
</style>
<div id="lnks">
  <table>
  <tr>
       <td>
       <a href="page1.htm" onclick="return loadExternal(this.href)">Page1</a>
     </td>
       <td>
            <a href="page2.htm" onclick="return loadExternal(this.href)">Page2</a>
     </td>
       <td>
            <a href="page3.htm" onclick="return loadExternal(this.href)">page3</a>
     </td>
  </tr>
  </table>
</div>


<div id="MainDisplay" style="position:absolute; top: 100px; width: 600px; height:auto; ">HELLO</div>
<iframe id="buffer" style="display:none; " name="buffer" src="page1.htm" onload="displayExternal();">Sorry, your browser does not support iframes.</iframe>

</body>
</html>
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…
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…

721 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