Solved

auto setting iframe height

Posted on 2010-11-11
9
506 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
[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
  • +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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
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…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

737 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