Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Iframe height adjust to remote page content

Posted on 2009-05-06
5
Medium Priority
?
927 Views
Last Modified: 2012-05-06
Hi there.

I have an html page that contains an iframe which shows content from another website. I need the iframe to height adjust based on the content height.  I found a solution in the knowledge base - http://www.experts-exchange.com/Q_22701504.html -  that works beautifully for IE but does not work at all for Firefox. I was wondering if it could be modified to work in FF or another solution could be provided. I have provided the code below.
<-- HTML PAGE --->
 
  <iframe name="myframe1" src="css-js/getremotefile.php?loc=http://www.msn.com" align="top" width="690" height="2000" frameborder="0" scrolling="no" marginheight="0"> </iframe> 
 
 
 
<--- getremotefile.php ----->
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
 
<body>
<?php
  readfile($_GET['loc']);
?>
</body>
</html>

Open in new window

0
Comment
Question by:allisonsabo74
  • 2
  • 2
5 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24324745
Which of the solutions in the other question did you try that did not work in FF?
0
 

Author Comment

by:allisonsabo74
ID: 24325022
ycTIN:

I looked at the link, tried the solution. It did not work.

mplungjan:
I used the solution posted by hach-que at 17/07/07 08:07 PM. The solution works in IE but not Firefox. Here it is below.
As for remote sites, you can use :

getremotefile.php :
<?php
  readfile($_GET['loc']);
?>

Then just tell the IFRAME to goto getremotefile.php?loc=http://www.remotesite.com
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 24325202
You need BOTH solutions.

Why would IE resize to content and FF not when you have no code that resizes the iframe???
0
 

Author Comment

by:allisonsabo74
ID: 24327437
mplungjan:
How right you are! I did have the other code in an external js file. Since it wasn't working I changed that code to the javascript mentioned on Dynamic Drive (http://www.dynamicdrive.com/dynamicindex17/iframessi.htm) and used it in conjunction with getremotefile.php. And here is my iframe code. it works perfectly in both FF and IE.
Thanks for making me take a closer look!

 <iframe id="myframe1" src="css-js/getremotefile.php?loc=http://www.externalsite.com" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:hidden; display:none;" width="690" scrolling="no" ></iframe>

Open in new window

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

916 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