Auto height iframe

swmasson

New Member
Hi there,

I'm trying to automatically resize the height of an iframe depending on the content of the webpage it displays...

basically i want word press to display within my current web template....

does anyone know of a code that works? i've tried at least 10 different codes and non actyually work...

Thanks for your help

Regards

SWM
 

jnjc

New Member
As far as I know you'll need to use some javascript to size the iframe. Do a search on it and you should see some examples.

HTH,
JC
 

swmasson

New Member
Thanks againa, however, i've searched all day and tried well over 10 examples... none seemed to work... i'm not sure its even possible...
 

Dronesypa

New Member
Its possible, however if you write a single line of text, that's how big your iframe is going to be. I am working on the same issue as you are. I have seen some people use a DIV and measure the length of it and set that to the iframe length.
 

Richardvd

New Member
It is possible with a JavaScript, but it don't works with all browsers. I had the same question a few months ago, the right solution for me was to use a div with scrollbar. An another chance was the positive influence for Google.
 

walkingbird

New Member
Do not use frames they are old technology. It will drastically effect the usability of your web site for users and search engines.
 

dumb_prog

New Member
Hi there,

I'm trying to automatically resize the height of an iframe depending on the content of the webpage it displays...

basically i want word press to display within my current web template....

does anyone know of a code that works? i've tried at least 10 different codes and non actyually work...

Thanks for your help

Regards

SWM

easy!

place a inner div inside iframe area

Get the height of the div, use this javascript.

function getHeight(){

var d=document;
var box=new Array("div id","div id 2");
for(x=0;x<box.length;x++){
h=d.getElementById(box[x]).offsetHeight;
for(y=0;y<box.length;y++){
test_h=d.getElementById(box[y]).offsetHeight;
if(h<test_h)h=test_h;
}

Once you get the height of the div, size your iframe height based on getheight().
 

athomas

New Member
That's not a good idea in and of itself though. Iframes aren't made to resize.

Use a php include like this:

<?php

if (isset($_GET['page'])) {
switch ($_GET['page']) {

case "something":
include ('something.php');
break;

default :
include 'home.php';
break;
}
} else {

include 'somefile.php';
}
?>


Just put that where you want to have the content come out, and have links look like this:

www.yoursite.com/index.php?page=something

Obiviously you can change something to whatever you want... Ask if it doesn't make sense.
 

jnjc

New Member
I might be missing something but to me this looks like it will only work for content located locally on the server. It won't work where the frame src is a url.

Likewise for the solution 'dumb_prog" sent in, to me (and again I might be missing something) looks like it would only work if the contents of the iframe are placed inside the div. I have a feeling that the poster whats to use an iframe along the lines of :

Code:
<iframe src="http://alinktosomething.com"></iframe>

and have the iframe resize automatically.

I have done a little bit of testing and I can't get anything to work either. In my opinion and based on the fact that I'm assuming you are trying to use an iframe as I have outlined above, I think it's time for plan b....

I've never used wordpress but I'm sure you'll be able to use an API to integrate it into your website..
 
Last edited:

athomas

New Member
Iframes aren't web 2.0 at all. It's old and frankly nobody really uses them that much anymore. Most sites arent even saved in *.html anymore.
 

dumb_prog

New Member
I might be missing something but to me this looks like it will only work for content located locally on the server. It won't work where the frame src is a url.

Likewise for the solution 'dumb_prog" sent in, to me (and again I might be missing something) looks like it would only work if the contents of the iframe are placed inside the div. I have a feeling that the poster whats to use an iframe along the lines of :

Code:
<iframe src="http://alinktosomething.com"></iframe>

and have the iframe resize automatically.

I have done a little bit of testing and I can't get anything to work either. In my opinion and based on the fact that I'm assuming you are trying to use an iframe as I have outlined above, I think it's time for plan b....

I've never used wordpress but I'm sure you'll be able to use an API to integrate it into your website..

I'm pretty sure it will work for frame src = url, since I have been using it on ajax (dynamically loads the content inside the div) as well.
 

jnjc

New Member
I'm pretty sure it will work for frame src = url, since I have been using it on ajax (dynamically loads the content inside the div) as well.

I could see how it would work with ajax because with an ajax call you will be putting the returned code into the div, the div will re-size itself and then your code will resize the iframe. With the <iframe src="url" ... no content goes into the div, hence the div will not re-size and your script won't work.

All this said I haven't had a chance to test it out so I'm not 100% sure....
 
Top