•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 428,368 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 3,474 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 JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 782 | Replies: 3
![]() |
•
•
Join Date: May 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Could someone tell me how to make an iframe resize based on the content without having to refresh the parent frame.
I have found some things that require java script in the frame document however i'm not sure how to integrate this, as the document my iframe links to is php not html.
I control both sides, parent and framed documents, so i just need to know what script to put where. Does anyone know how to do this?
Thanks
I have found some things that require java script in the frame document however i'm not sure how to integrate this, as the document my iframe links to is php not html.
I control both sides, parent and framed documents, so i just need to know what script to put where. Does anyone know how to do this?
Thanks
•
•
Join Date: May 2008
Posts: 32
Reputation:
Rep Power: 1
Solved Threads: 2
Hi,
I didn't really know what you ment by this question so I have answered the two possibility's to the best of my knowledge.
You could just add PHP tags into your IFrame tag:
And add in some variables earlier in the page.
If you wanted to resize the IFrame from inside It I don't think you could do that.
Regards,
Sam Rudge
I didn't really know what you ment by this question so I have answered the two possibility's to the best of my knowledge.
You could just add PHP tags into your IFrame tag:
<iframe frameborder="0" scrolling="no" height="<?php print($Hight); ?>" width="<?php print($Width); ?>" src="/page.php" />
And add in some variables earlier in the page.
If you wanted to resize the IFrame from inside It I don't think you could do that.
Regards,
Sam Rudge
•
•
Join Date: May 2008
Posts: 32
Reputation:
Rep Power: 1
Solved Threads: 2
On second thoughts I think there might be a way but it might be tricky.
If you used $_SESSION variables you could probably do it but you would have to reload the main page.
On the main page insert this PHP along with the IFrame HTML:
Then on page.php (The page requested in the IFrame) put in this code:
When the user clicks on the link there main browser will be sent to the same page but the $_SESSION variable 'Resize' would be set so it would use the second set of dimensions.
Regards,
Sam Rudge
P.S. You would probably get more help if you posted this in the PHP forum on this site.
If you used $_SESSION variables you could probably do it but you would have to reload the main page.
On the main page insert this PHP along with the IFrame HTML:
<?php
session_start();
if ( !isset($_SESSION["Resize"]) ) {
/* This is what happens the first time the person visits the page */
$Hight = "100px";
$Width = "120px";
} else {
/* This is if the Session has been set */
$Hight = "20px";
$Width = "50px";
};
?>
<iframe frameborder="1" scrolling="no" height="<?php print($Hight); ?>" width="<?php print($Width); ?>" src="/page.php" />Then on page.php (The page requested in the IFrame) put in this code:
<?php session_start(); $_SESSION["Resize"] = "1"; ?> <a href="/page_with_iframe_on.php" target="_top">Some Link</a>
When the user clicks on the link there main browser will be sent to the same page but the $_SESSION variable 'Resize' would be set so it would use the second set of dimensions.
Regards,
Sam Rudge
P.S. You would probably get more help if you posted this in the PHP forum on this site.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Dynamic iFrame height, not working in ie without refresh. (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: refresh
- Next Thread: Page only works in FF


Linear Mode