Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

big_malk

macrumors 6502a
Original poster
Aug 7, 2005
557
1
Scotland
I have a website that uses an iFrame and a menu that has links targeting it, they all work fine until the iFrame content has a PHP redirect, then the links open in a new window.
I'm guessing the new headers somehow interfere with the iFrame title, is there some way to use Javasacript for the menu links instead that target it by ID, or something like that? Or a different type of redirect that won't affect the iFrame.
 
Do you really need to use an iframe?

I'm having trouble following your setup. Can you give some code snippets or something that would help make it clearer? Like examples of how you're doing the links as one example and also what you're doing in the PHP.
 
Do you really need to use an iframe?

I'm having trouble following your setup. Can you give some code snippets or something that would help make it clearer? Like examples of how you're doing the links as one example and also what you're doing in the PHP.

The iFrame contains a game that uses CSS absolute positioning to move cards around, it's probably do-able in a div but this seemed by far the easiest way.

This is the HTML code in the page:
HTML:
<div id="main_menu_container">
	<ul id="main_menu">
		<li class="left"><a href="/game/find_table/" target="game_container">Tables</a></li>
		<li class="middle"><a href="/game/quickplay/" target="game_container">Quickplay</a></li>
		...
	</ul>
</div>

<iframe src="/game/find_table/" id="game_container" scrolling="no" name="game_container" ></iframe>
I've tried changing the ID and name of the iFrame but that makes no difference.

All the links in the menu work fine and load in the iFrame no problem, at first. When a player clicks 'Quickplay', the iFrame loads /game/quickplay/ which sets up a table for them then redirects to something like /game/load_table/1234/ using this PHP code (I'm using CodeIgniter for this btw):

PHP:
function quickplay() {
	$table = $this->gc->create_table("Quickplay");
	$this->gc->join_table($table['tableID']);
	$this->gc->add_bot_to_table($table['tableID']);
	header('location: /game/load_table/'.$table['tableID']);
}

That works fine too, but after the redirect (I'm assuming that's what's causing it, I can't think what else it could be) all the links in the menu open in a new window, as if the browser can't find 'game_container' anymore.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.