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:

if($send_back_to_form == "yes") {
$redirect_to = $form_page_name."?done=1";
} else {
$redirect_to = $success_page;
}

===> 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!!

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

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

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 :icon_rolleyes: )
Sam Rudge

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:

if($send_back_to_form == "yes") {
$redirect_to = $form_page_name."?done=1";
} else {
$redirect_to = $success_page;
}

===> 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,

Right then,
this should work (If it doesn't then i'm out of ideas)

<?php
include('config.php'); //Include the config file

if($send_back_to_form == "yes") {

$redirect_to = $form_page_name."?done=1";
} else {
$redirect_to = $success_page;
}
//Output a page that sends the parent page to somewhere (Not the IFrame)
//This page has no content other than standard HTML and JS
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
<!--
function outsideframe() {
	opener.location = '<?php echo $redirect_to; ?>';
}
//-->
</script>
</head>

<body onload="javascript:outsideframe()">
<!-- In the rare case a user don't have javascript -->
<a href="<?php echo $redirect_to; ?>" target="_parent">Click To Continue</a>
</body>
</html>

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 :D
Hope that works for you,
Regards,
Sam Rudge

I have a frame breakout in succcess.page.php

<script type='text/javascript' language='javascript'>
  if (top.location != location) { 
 top.location.href = document.location.href ;
  }
</script>

or

<script type='text/javascript' language='javascript'>
if (parent.frames.length > 0) {
    parent.location.href = self.document.location
}
</script>

degrades badly if javascript disabled

Thank you very much for your help, I just did it somehow :D

Really appreciated!!

Cheers!

This article has been dead for over six months. Start a new discussion instead.