Solved

auto setting iframe height

Posted on 2010-11-11
9
495 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
using web browser with BING 40 89
angularls and plnkr 14 19
Angular 2 complaining about map file 7 6
Birthdays 3 22
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now