User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: May 2008
Posts: 5
Reputation: nizuya is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
nizuya nizuya is offline Offline
Newbie Poster

Dynamically resize iframe containing php

  #1  
May 26th, 2008
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2008
Posts: 32
Reputation: samarudge is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
samarudge samarudge is offline Offline
Light Poster

Re: Dynamically resize iframe containing php

  #2  
May 27th, 2008
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:

<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
Reply With Quote  
Join Date: May 2008
Posts: 32
Reputation: samarudge is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
samarudge samarudge is offline Offline
Light Poster

Re: Dynamically resize iframe containing php

  #3  
May 27th, 2008
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:
<?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.
Reply With Quote  
Join Date: May 2008
Posts: 5
Reputation: nizuya is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
nizuya nizuya is offline Offline
Newbie Poster

Re: Dynamically resize iframe containing php

  #4  
May 27th, 2008
Thanks a lot Sam.
The second is sort of what I was thinking, I'll give it a try. If it doesn't work I try posting in the PHP section.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:54 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC