Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Correct cross-browser iFrame format

Posted on 2009-07-02
8
Medium Priority
?
773 Views
Last Modified: 2013-11-19
Hi experts.

I'm using an iFrame to display content from one of my sites onto another site.  Bellow is the code I'm using (the full page).   You'll see I'm using a 100% for width and also a 100% for height so that the iFrame displays "at full" on any computer regardless of what display the person has.  This works great on most browsers except for Firefox. On Firefox it gets the 100% width but it displays no height. I shows only a "little height". I've tried playing with different heights but it doesn't quite work. I'd like to have something that displays correctly on any computer.

How do I need to set up this iFrame so that it displays properly on any browser?

Please help I don't know what elso to try to fix!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="shortcut icon" href="/favicon.ico" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="ROBOTS" content="ALL" />
<title>My iFrame site</title>
</head>
 
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" bgcolor="#666666">
<iframe src="http://www.mysite.com/doc/2009062201/" height="100%" frameborder="0" marginwidth="0" marginheight="0" width="100%"></iframe>
</body>
</html>

Open in new window

0
Comment
Question by:JackoPinto
[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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 8

Expert Comment

by:Wikkard
ID: 24769451
Try setting the css style for the iframe element.

ie.
<iframe src="http://www.mysite.com/doc/2009062201/" height="100%" frameborder="0" marginwidth="0" marginheight="0" width="100%" style="height:100%; width:100%"></iframe>

There are a number of height/width related css properties, Im thinking you might be interested in min-height which allows you to set a minimum height for elements. They can grow but not shrink. see http://www.w3schools.com/CSS/pr_dim_min-height.asp

0
 

Author Comment

by:JackoPinto
ID: 24769625
Thanks.

What would you recommend as a minimum height for better browser compatibility? What would work the best? This is what I have.
<iframe src="http://www.mysite.com/2009062201/" height="100%" frameborder="0" marginwidth="0" marginheight="0" width="100%" style="height:100%; width:100%; min-height:730px;"></iframe>

Open in new window

0
 
LVL 8

Expert Comment

by:Wikkard
ID: 24769662
It all depends on your html layout. If you definitely want the iframe to take up the full page (cloaking) then set the width and height to 100%, I only mentioned the min-height to show that their are alot of css features that you might find useful.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:JackoPinto
ID: 24769683
Thanks.

I would need a recommended html layout for iFrame to take up the full page.  Please help! Thanks.
0
 
LVL 1

Accepted Solution

by:
ibs06t earned 1500 total points
ID: 24771482
here i attached height coding for all user screen resolution
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript">
function wrk()
{
var a= window.screen.availHeight -'149' ;
document.getElementById('sa').style.height= a +'px';
alert(document.getElementById('sa').style.height);
}
</script>
<style type="text/css">
 
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
 
</style></head>
<body onload="wrk();">
<iframe id="sa" src="http://in.yahoo.com" width="100%" frameborder="0" scrolling="no"></iframe>
</body>
</html>

Open in new window

0
 

Author Comment

by:JackoPinto
ID: 24772907
Thanks.

Once published and called upon, Firefox gives me an alert message that says:  The page at http://www.mysite.com says: 815 px

What is that?

Should't the iframe adjust to the size of any resolution?

Thanks for the comments.
0
 
LVL 1

Expert Comment

by:ibs06t
ID: 24776009
yes  iframe adjust the height any screen resolution..

pl comment that alert.

its fullly working in any screen resolution
0
 
LVL 30

Expert Comment

by:IanTh
ID: 24776922
dont use i-frame
The iframe element is not supported in HTML 4.1 Strict DTD and in XHTML 1.0 Strict DTD.
from
http://www.w3schools.com/TAGS/tag_iframe.asp

use templates to create pages and use proper div based pages instead of iframe's
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to dynamically set the form action using jQuery.

719 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