By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,830 Members | 2,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,830 IT Pros & Developers. It's quick & easy.

Changing frame location

P: 46
I have a script running in a frame. This script needs to be able to redirect the browser to an entirely different location. However, with the header("location: ") method, only that frame's source is changed. How would I redirect the browser away from those frames?
Feb 26 '08 #1
Share this Question
Share on Google+
8 Replies


ronverdonk
Expert 2.5K+
P: 4,258
Use a JavaScript function and issue
Expand|Select|Wrap|Line Numbers
  1. top.frames['thatframe'].location.href = 'yourpage.htm'; 
where 'thatframe' is the name of the frame you want it to be redirected.

Ronald
Feb 26 '08 #2

P: 46
Use a JavaScript function and issue
Expand|Select|Wrap|Line Numbers
  1. top.frames['thatframe'].location.href = 'yourpage.htm'; 
where 'thatframe' is the name of the frame you want it to be redirected.

Ronald
Ok, but this is conditional based on some PHP variable. How do i get it only to issue that command when that PHP if statement passes?
Feb 26 '08 #3

ronverdonk
Expert 2.5K+
P: 4,258
Show your php code that does the redirect. And enclose it within code tags.

Ronald
Feb 26 '08 #4

P: 46
Well its pretty simple. So far its just
[php]
if($myVar==$target){
header("Location: http://my.server.com");
}
[/php]
But this code is running in a frame, so the redirection only applies to that frame's source, instead of the browser itself.

Hope that makes sense...
Feb 27 '08 #5

P: 46
Kinda stuck here :(
Any suggestions?
Feb 28 '08 #6

ronverdonk
Expert 2.5K+
P: 4,258
Have you tried this one:[php]<?php
if($myVar==$target){
?>
<script>
top.frames['thatframe'].location.href = 'yourpage.php';
</script>
<?php
exit;
}
?>[/php]Ronald
Feb 28 '08 #7

P: 46
Thanks alot for you help :) I had no idea you could mix the two languages like that. Works like a charm
Feb 28 '08 #8

ronverdonk
Expert 2.5K+
P: 4,258
Yes you can mix.Glad it is solved. See you again next time.

Ronald
Feb 28 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.