Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

auto setting iframe height

Posted on 2010-11-11
9
Medium Priority
?
523 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 1000 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 1000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Suggested Courses

877 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