Killing / Releasing IFrame

Reply

Join Date: Jan 2009
Posts: 3
Reputation: shah0101 is an unknown quantity at this point 
Solved Threads: 0
shah0101 shah0101 is offline Offline
Newbie Poster

Killing / Releasing IFrame

 
0
  #1
Jan 11th, 2009
Hi there,

I have a problem that I have called a PHP script in IFRAME and I want to release that IFRAME once the tasks are completed.

Parts of the scripts are as follows:


Process_form.php:
  1. if($send_back_to_form == "yes") {
  2. $redirect_to = $form_page_name."?done=1";
  3. } else {
  4. $redirect_to = $success_page;
  5. }

===> I need $success_page to load without any frames <====

Config.php:
$success_page = "thanks.php";

Thanks.php:
echo '<meta http-equiv="refresh" content="5;url=http://www.mysite.com/index.php" />'

Any help will be appreciated to sort the problem out please.

===> I need $success_page to load in the same browser releasing the previous IFRAME <====


Cheers!!
Last edited by peter_budo; Jan 11th, 2009 at 2:30 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 257
Reputation: samarudge is an unknown quantity at this point 
Solved Threads: 20
samarudge samarudge is offline Offline
Posting Whiz in Training

Re: Killing / Releasing IFrame

 
0
  #2
Jan 11th, 2009
you should be able to do it with a bit of javascript
  1. <?php
  2. echo '<script type="text/javascript">';
  3. echo"parent.window.location = $success_page";
  4. echo'</script>';
  5. ?>
that should work or you could send a link that the user would have to click on with a target of _top
  1. <?php
  2. echo"<a href=\"$success_page\" target=\"_top\">Click Here</a>";
  3. ?>
Hope that works
Rgds,
Sam Rudge
Last edited by peter_budo; Jan 11th, 2009 at 2:31 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
My Blog, Life and everything that matters to me - SamRudge.co.uk

2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 257
Reputation: samarudge is an unknown quantity at this point 
Solved Threads: 20
samarudge samarudge is offline Offline
Posting Whiz in Training

Re: Killing / Releasing IFrame

 
0
  #3
Jan 11th, 2009
Originally Posted by samarudge View Post
you should be able to do it with a bit of javascript
<?php
echo '<script type="text/javascript">';
echo"parent.window.location = $success_page";
echo'</script>';
?>
that should work or you could send a link that the user would have to click on with a target of _top
<?php
echo"<a href=\"$success_page\" target=\"_top\">Click Here</a>";
?>
Hope that works
Rgds,
Sam Rudge
I think you could also use opener.location instead of parent.window.location, that might work better.
Rgds (Again ),
Sam Rudge
My Blog, Life and everything that matters to me - SamRudge.co.uk

2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 257
Reputation: samarudge is an unknown quantity at this point 
Solved Threads: 20
samarudge samarudge is offline Offline
Posting Whiz in Training

Re: Killing / Releasing IFrame

 
0
  #4
Jan 11th, 2009
Originally Posted by samarudge View Post
I think you could also use opener.location instead of parent.window.location, that might work better.
Rgds (Again ),
Sam Rudge
Um, i feel kinda stupid as i have answered this post twice already but you actualy need
self.parent.location=
in the javascript not parent.window.location or opener.location

Rgds (Yes again )
Sam Rudge
My Blog, Life and everything that matters to me - SamRudge.co.uk

2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 3
Reputation: shah0101 is an unknown quantity at this point 
Solved Threads: 0
shah0101 shah0101 is offline Offline
Newbie Poster

Re: Killing / Releasing IFrame

 
0
  #5
Jan 11th, 2009
Dear Sam,

Really appreciated!!

But none of these worked!! I don't know why, may be the placement of the script was not appropriate. Actually three different files are working alongside, can you please be more specific where I should place this script please?

File no. 1 is: Process_form.php:
  1. if($send_back_to_form == "yes") {
  2. $redirect_to = $form_page_name."?done=1";
  3. } else {
  4. $redirect_to = $success_page;
  5. }

===> I need $success_page to load without any frames <====

File no. 2 is: Config.php:
$success_page = "thanks.php";

File no.3 is: Thanks.php:
echo '<meta http-equiv="refresh" content="5;url=http://www.mysite.com/index.php" />'

Kindest Regards,
Last edited by peter_budo; Jan 11th, 2009 at 2:31 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 257
Reputation: samarudge is an unknown quantity at this point 
Solved Threads: 20
samarudge samarudge is offline Offline
Posting Whiz in Training

Re: Killing / Releasing IFrame

 
0
  #6
Jan 11th, 2009
Right then,
this should work (If it doesn't then i'm out of ideas)
  1. <?php
  2. include('config.php'); //Include the config file
  3.  
  4. if($send_back_to_form == "yes") {
  5.  
  6. $redirect_to = $form_page_name."?done=1";
  7. } else {
  8. $redirect_to = $success_page;
  9. }
  10. //Output a page that sends the parent page to somewhere (Not the IFrame)
  11. //This page has no content other than standard HTML and JS
  12. ?>
  13. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  14. <html xmlns="http://www.w3.org/1999/xhtml">
  15. <head>
  16. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  17. <script type="text/javascript">
  18. <!--
  19. function outsideframe() {
  20. opener.location = '<?php echo $redirect_to; ?>';
  21. }
  22. //-->
  23. </script>
  24. </head>
  25.  
  26. <body onload="javascript:outsideframe()">
  27. <!-- In the rare case a user don't have javascript -->
  28. <a href="<?php echo $redirect_to; ?>" target="_parent">Click To Continue</a>
  29. </body>
  30. </html>
  31.  
Copy that code onto Process_form.php (Backup the original though) and see how that works. I wonder if this would count towards my IT GCSE
Hope that works for you,
Regards,
Sam Rudge
My Blog, Life and everything that matters to me - SamRudge.co.uk

2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,385
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 167
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Killing / Releasing IFrame

 
0
  #7
Jan 11th, 2009
I have a frame breakout in succcess.page.php
  1. <script type='text/javascript' language='javascript'>
  2. if (top.location != location) {
  3. top.location.href = document.location.href ;
  4. }
  5. </script>
or
  1. <script type='text/javascript' language='javascript'>
  2. if (parent.frames.length > 0) {
  3. parent.location.href = self.document.location
  4. }
  5. </script>
degrades badly if javascript disabled
Last edited by almostbob; Jan 11th, 2009 at 11:40 am.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 3
Reputation: shah0101 is an unknown quantity at this point 
Solved Threads: 0
shah0101 shah0101 is offline Offline
Newbie Poster

Re: Killing / Releasing IFrame

 
0
  #8
Jan 12th, 2009
Thank you very much for your help, I just did it somehow

Really appreciated!!

Cheers!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC