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
Solved

auto setting iframe height

Posted on 2010-11-11
9
502 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

839 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