Links targeting iFrame don't work after redirect

Discussion in 'Web Design and Development' started by big_malk, Mar 12, 2010.

  1. big_malk macrumors 6502a

    Aug 7, 2005
    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.
  2. angelwatt Moderator emeritus


    Aug 16, 2005
    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.
  3. big_malk thread starter macrumors 6502a

    Aug 7, 2005
    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:
    <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>
    <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):

    function quickplay() {
    $table $this->gc->create_table("Quickplay");
    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.
  4. big_malk thread starter macrumors 6502a

    Aug 7, 2005
    Sorry for the bump, but does no one have any advice for this problem? :)

Share This Page