Solved

auto setting iframe height

Posted on 2010-11-11
9
503 Views
Last Modified: 2012-05-10
Hi,

I am really struggling to auto set the height of an iframe with variable content on a client site.
Can anyone suggest the best way, javasript enabled and not enabled?

I have tracked a few previous posts but with limited success.

Cheers
0
Comment
Question by:Lmillard
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 6

Expert Comment

by:Chorch
ID: 34110996
Hello

against what do you want to set this auto height? Div height? Cell/column height? ...

0
 

Author Comment

by:Lmillard
ID: 34111090
I have a div with an ID of frameContent but the frame content is being served by another source over which we have no control so there is nothing to go with. At the moment I just have to set the iframe height attribute to 1600px to avoid overflow but this just looks messy
0
 
LVL 6

Expert Comment

by:Codebot
ID: 34111690
use 100% or 80%. it will adjusted itself automatically
0
Independent Software Vendors: 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!

 
LVL 6

Expert Comment

by:Codebot
ID: 34111734
use something like that

<iframe allowtransparency=true frameborder=0 id=rf  scrolling=auto src="http://www.externaldomain.com/" style="width:100%;height:100%"></iframe>
0
 

Author Comment

by:Lmillard
ID: 34112404
I have tried putting the height to 100% and 80% using the iframe attributes and the css but neither seem to work.  
I am now using a blank test page with nothing else but the iframe and it defaults to about 150px with an autoscroll
0
 
LVL 44

Accepted Solution

by:
scrathcyboy earned 250 total points
ID: 34116275
Percentage height do NOT WORK on an iframe.  They have to be REAL pixel heights.  There is a method of autosetting the Iframe height, but I have not tried it, and can't say if it works or not.  My experience is that these methods do not work for Iframes.  The other error is to put an IFRAME in a DIV.  Remove the DIV that encloses it, it does not mean anything to the iframe.

A DIV is a component element of a web page that interacts with other DIV components.  An IFRAME is NOT this -- it is a separate PAGE in a PAGE -- think of it like a HOLE cut out in your page, where you see another web page underneath yours.  How big do you cut the hole?  AHA, that is the problem, it has to be defined.

To test for scalable code, check these -- try them to see if they work --

www.mattcutts.com/blog/iframe-height-scrollbar-example/
http://www.appnitro.com/forums/topic/auto-expandadjustable-iframe
http://w3schools.invisionzone.com/index.php?showtopic=26417
0
 

Assisted Solution

by:ddaanniieelluk
ddaanniieelluk earned 250 total points
ID: 34119275
We tried to do this for a web application to go on a tv screen, but after days of hunting and looking for solutions we found nothing.

The simple fact is, the content you're displaying in the iframe is on a completely separate website, so unless you have access to change some code on the website being viewed.. it's not possible.

What you'd have to do is get the client website to send out the height, and your website read this value. There is no way of your website auto-detecting the height.
0
 

Author Comment

by:Lmillard
ID: 34119701
The methods described in the links provided by scrathcyboy do work BUT only when including a page located on the same server or within the same domain. I presume this is a security measure to do with javascripts restrictions for cross domain/server execution??

0
 

Expert Comment

by:ddaanniieelluk
ID: 34120361
That's exactly right.

It's possible to do it when on the same server, or same domain, but when it's someone else's website you start having problems. As you said, it's a security measure with javascript.
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

756 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