•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 423,518 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,453 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 26300 | Replies: 13
![]() |
Hi I'm trying to find a script that dynamically resizes the iframe to be the height of the page contained within it
The iframe page I am accessing is an external domain page.
I know due to security reasons normally all external pages loaded into the iframe must be from the same domain as the page the iframe tag is inserted. My twist is I can add codes to the external domain source page. I was wondering in this case is there a way to work around this issue so I can dynamically resize my parent iframe?
This is the closest thing I found, except it doesn't work for external pages on different domains.
http://www.dynamicdrive.com/dynamici...iframessi2.htm
Thanks much!!
The iframe page I am accessing is an external domain page.
I know due to security reasons normally all external pages loaded into the iframe must be from the same domain as the page the iframe tag is inserted. My twist is I can add codes to the external domain source page. I was wondering in this case is there a way to work around this issue so I can dynamically resize my parent iframe?
This is the closest thing I found, except it doesn't work for external pages on different domains.
http://www.dynamicdrive.com/dynamici...iframessi2.htm
Thanks much!!
Not really the solution you are looking for, but you could use a php script to cache the pages locally on your server. What are you trying to do exactly. I would be very careful using content from someone elses sight in this way....
Dance
Dance
Thanks for the tip. I don't know much about php but I will research...
Actually I'm trying to pull external content into my site - legally, of course. I do have the permission to do so from the external domain. Their page height fluctuates though, so I wanted to see if I can make my iframe height change dynamically to fix all of their content without scroll bar.
I guess I can just ask the external site people to give me an estimate of what their longest pages are, so I can set my iframe to the maximum height.
Actually I'm trying to pull external content into my site - legally, of course. I do have the permission to do so from the external domain. Their page height fluctuates though, so I wanted to see if I can make my iframe height change dynamically to fix all of their content without scroll bar.
I guess I can just ask the external site people to give me an estimate of what their longest pages are, so I can set my iframe to the maximum height.
This should work for you:
[PHP]<?php
// Edit these...
$page_to_cache = "http://www.theirdomain.com/pagetocache.html";
$page_to_write = 'mycachedpage.html';
// Do not edit below...
$cache = file_get_contents($page_to_cache);
$fh = fopen($page_to_write, 'wt');
fwrite($fh, $cache);
fclose($fh);
?>[/PHP]
You can contact your host to setup a cron job, or possibly do it in the cpanel.
Dance
[PHP]<?php
// Edit these...
$page_to_cache = "http://www.theirdomain.com/pagetocache.html";
$page_to_write = 'mycachedpage.html';
// Do not edit below...
$cache = file_get_contents($page_to_cache);
$fh = fopen($page_to_write, 'wt');
fwrite($fh, $cache);
fclose($fh);
?>[/PHP]
You can contact your host to setup a cron job, or possibly do it in the cpanel.
Dance
dance instructor> Thanks for the code. Our site doesn't work with cache (due to other code/database related issues) so we ended up just asking the external site to tell us their best guess of page height.
shiznatix> If you go to http://www.dynamicdrive.com/dynamici...iframessi2.htm the code there should help you - I think...
shiznatix> If you go to http://www.dynamicdrive.com/dynamici...iframessi2.htm the code there should help you - I think...
•
•
Join Date: Apr 2006
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I think it was already mentioned here but I am pulling out my hair as well...
My problem is, that I want the iframe to adapt the hight of the importet document WITHOUT there being scrollbars but the iframe adapting to the hight of the document.
My first tries went towards my coppermine gallery which is on THIS soul server in my house but yet under a different v-host. None the less... I read, that external URLs would not work because iframe couldn't figure out how high the imported document is...
Having read this I was rather demotivated but went ahead and built all the documents into the wwwroot which made them "local" BUT still no working iframe as I'd define it beacuse the doc - even when loaded locally - still has scroll bars to it.
Now I don't know what to do and where I went wrong and would be very happy, if anyone could help me out here.
Regards
Lars Hilse
My problem is, that I want the iframe to adapt the hight of the importet document WITHOUT there being scrollbars but the iframe adapting to the hight of the document.
My first tries went towards my coppermine gallery which is on THIS soul server in my house but yet under a different v-host. None the less... I read, that external URLs would not work because iframe couldn't figure out how high the imported document is...
Having read this I was rather demotivated but went ahead and built all the documents into the wwwroot which made them "local" BUT still no working iframe as I'd define it beacuse the doc - even when loaded locally - still has scroll bars to it.
Now I don't know what to do and where I went wrong and would be very happy, if anyone could help me out here.
Regards
Lars Hilse
•
•
Join Date: Feb 2006
Posts: 49
Reputation:
Rep Power: 3
Solved Threads: 1
Site admin at NetBulge.com, a place set out to improve the web 1 good article at a time :)
•
•
Join Date: Apr 2006
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Yes... but I wasn't able to make it work... what else to I have to look upon while writing the script?
The page is located at http://hg2.serveftp.net/larhil2 - could be, that it is quite a mess by now.
The page is located at http://hg2.serveftp.net/larhil2 - could be, that it is quite a mess by now.
•
•
Join Date: Feb 2006
Posts: 49
Reputation:
Rep Power: 3
Solved Threads: 1
Well, yes, some things are quite a mess. I'm particularly worried about your unclosed
in the middle of the page, that is a HUGE no-no.
A web page can only have 1 <body> declaration, and your is a few lines back:
To have both onload requests merge you would want to delete the <body> in the middle of the page and change the first one to:
But before the goSetHeight() call can work, you first need to add to your page a goSetHeight() function declaration along with all the scripting found at the link I gave you.
I would also STRONGLY encourage you to remake the page from scratch. Some parts are terribly messy and are bound to hurt the render in one browser or the other.
<body onload="goSetHeight()">
in the middle of the page, that is a HUGE no-no.
A web page can only have 1 <body> declaration, and your is a few lines back:
<body onload="MM_preloadImages('imagetank/button02.jpg','imagetank/button02-PHOTO.jpg','imagetank/button02-WEB.jpg','imagetank/button02-HOME.jpg')">To have both onload requests merge you would want to delete the <body> in the middle of the page and change the first one to:
<body onload="MM_preloadImages('imagetank/button02.jpg','imagetank/button02-PHOTO.jpg','imagetank/button02-WEB.jpg','imagetank/button02-HOME.jpg'); goSetHeight()">But before the goSetHeight() call can work, you first need to add to your page a goSetHeight() function declaration along with all the scripting found at the link I gave you.
I would also STRONGLY encourage you to remake the page from scratch. Some parts are terribly messy and are bound to hurt the render in one browser or the other.
Site admin at NetBulge.com, a place set out to improve the web 1 good article at a time :)
![]() |
•
•
•
•
•
•
•
•
DaniWeb HTML and CSS Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Dynamic iframe height (JavaScript / DHTML / AJAX)
- Dynamic iFrame height, not working in ie without refresh. (JavaScript / DHTML / AJAX)
- iframe help - Height (HTML and CSS)
Other Threads in the HTML and CSS Forum
- Previous Thread: Complicated CSS, Noob Needs Help!!! =)
- Next Thread: problem with DW CSS Horizontal Spry


Linear Mode