Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect parent from iframe page

Status
Not open for further replies.

3Y3

Programmer
Sep 18, 2001
45
CA
Hi

I'm working with a few pages that include the google maps api, and as a result I needed to implement a simple iframe fix for IE browsers.

In one case I need the page loaded in my iframe to redirect the parent page. This redirect is triggered on a form submit.
Currently this is the form action
<form id="searchForm" name="searchForm" method="post" action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>">

and once it refreshes it triggers the following code (since I have a hidden field named process)

if ($_POST['process'] == 1) {
redirect(" }



any possible way for php to target the parent page with the redirect / find out if its trapped in an iframe at that point?
 
PHP has no awareness if it is inside a frame or on a single page, so php has no capabilities of referencing other frames. You would need to do that via html or javascript.
 
I came up with this solution, but its only working in Firefox for some reason and not IE.

When the user submits and triggers the above $_POST['process'] if statement I jump to javascript and do the redirect, or am I insane for thinking this is possible due to the timing of php.

<?
if ($_POST['process'] == 1) {
?>
<script>
if (parent.location.href == self.location.href) {
alert ("Redirecting...")
window.location.href = ' </script>

<?
}
?>

Like I mentioned, it fires off and redirects fine in firefox (oh how I love thee) and I can see the alert, but in IE it simply looks like the page refreshes and does not trigger anything (no alert or redirect).
Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top