IE8 Php标题位置打开一个新窗口

时间:2012-06-12 14:08:04

标签: php search iframe header window

我有一个动态填充PHP和数据库内容的页面,内容被加载到iframe中。现在,当我进行自定义搜索时,结果在所有浏览器上都很好,但IE8(可能是早期版本)。浏览器在新窗口中对结果进行排序,而不是填充iframe!

我的php搜索页面:

    <?php
if (isset($_REQUEST[searchname])) {
    $searchname = $_REQUEST[searchname];

    if (strlen($searchname) < 3) {
        $location = "necrologies_iframe.php?action=tooshort";
        header("Location: {$location}");
    } else {
        $location = "necrologies_iframe.php?action=search&nom={$searchname}";
        header("Location: {$location}");
    }
}
?>

有没有办法用结果填充iframe而不是打开新窗口?

修改

搜索表单/按钮:

<form id="form1" name="form1" method="get" target="frame" action="http://www.cablevision.qc.ca/fr/code/necrologies_search.php">
<p><strong><a href="javascript:void(0);" onClick="necro_search('est');" >Abitibi-Est</a> |  <!--//href="index.php?option=com_content&amp;view=article&amp;id=123&amp;Itemid=146&amp;action=est-->
    <a href="javascript:void(0);" onClick="necro_search('ouest');" >Abitibi-Ouest</a> |     <!--//href="index.php?option=com_content&amp;view=article&amp;id=123&amp;Itemid=146&amp;action=ouest"-->
    <a href="javascript:void(0);" onClick="necro_search('rn');" >Rouyn-Noranda</a> |        <!--//href="index.php?option=com_content&amp;view=article&amp;id=123&amp;Itemid=146&amp;action=rn"-->
    <a href="javascript:void(0);" onClick="necro_search('temis');">T&eacute;miscamingue</a> <!--//href="index.php?option=com_content&amp;view=article&amp;id=123&amp;Itemid=146&amp;action=temis"-->
    </strong> |
<input name="searchname" type="text" id="searchname" value=<?php if (isset($_REQUEST[nom])) { echo '"' . $_REQUEST[nom] . '"'; } else { echo '"rechercher les archives"'; } ?> size="25" />
<input type="submit" name="submit" id="submit" value="Rechercher" />

页面的iframe部分

<iframe id="frame" "width="638px" frameborder="0" src="code/necrologies_iframe.php" scrolling="yes" horizontalscrolling="no" verticalscrolling="yes"></iframe>

iframe页面代码

 <style type="text/css">
<!--
table
{
    line-height: 135%;
    font-family: Arial, Helvetica, sans-serif;
    font-size:13px;
}
.border {
    border: 1px solid #000000;
}

.borderbas {
    border-bottom: 1px solid #000000;
}

.padding {
    padding: 5px;
}
-->
</style>
<?php
// fichier de connection a la DB
require_once("includes/connection.php");
require_once("includes/functions.php");
?>



<?php
$action = $_REQUEST[action];
$datedujour = date("Y-m-d");
switch ($action) {
    case "search":
        $searchname = utf8_decode(mysql_prep($_REQUEST[nom]));
        $necroresult = mysql_query("SELECT * FROM necrologies WHERE nom LIKE '%{$searchname}%' AND approuve = '1' ORDER BY id DESC ");
        if (mysql_affected_rows() == 0) {
            // message que je fais afficher si il ne trouve rien (au lieu d'une page blanche qui ne veux rien dire
            $message = "<br /><br /><br /><br /><h3>Aucun r&eacute;sultat trouv&eacute; </h3><br>Veuillez modifier le nom de la recherche...<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />";
        } else {
            // sinon on affiche le nombre de resultats trouvés
            $necro_num_rows = mysql_num_rows($necroresult);  
            $message = $necro_num_rows . " r&eacute;sultat(s) trouv&eacute;s...";
            $affiche_liste = 1;
        }
        break;

    case "tooshort":
        echo "<br><br><center>Recherche trop courte, veuillez entrer plus de 4 caract&egrave;res...</center><br><br><br><br><br><br><br><br><br><br><br><br><br>";
        break;

    case "est":
    case "ouest":
    case "rn":
    case "temis":
        $affiche_liste = 1; // pour faire afficher la liste des necro
        $necroresult = mysql_query("SELECT * FROM necrologies WHERE datefin > '{$datedujour}' AND approuve = '1' AND region = '{$action}' ORDER BY id DESC ");
        break;
    default:
        // default on vois toutes les necro de toute les regions
        $necroresult = mysql_query("SELECT * FROM 
            necrologies WHERE datefin > '{$datedujour}' AND approuve = '1' 
            ORDER BY id DESC ");
        $affiche_liste = 1;
}
?>


<br />



<?php
// affichage du message
if (isset($message)) { 
    echo "<br><strong><center>" . $message . "</strong></center><br>";
}

// liste des necro dans des tables
if ($affiche_liste == 1 || !isset($_REQUEST[action])) { 
    while ($row = mysql_fetch_array($necroresult)) {



    ?>

    <!-- Debut de la table fancy round corner -->
    <div align="center">
      <table  border="0" align="left" cellpadding="0" cellspacing="0" class="tb">
        <tr>
          <td width="16"><img src="/fr/images/roundtable/top_lef.gif" width="16" height="16"></td>
          <td height="16" background="/fr/images/roundtable/top_mid.gif"><img src="/fr/images/roundtable/top_mid.gif" width="16" height="16"></td>
          <td width="24"><img src="/fr/images/roundtable/top_rig.gif" width="24" height="16"></td>
        </tr>
        <tr>
          <td width="16" background="/fr/images/roundtable/cen_lef.gif"><img src="/fr/images/roundtable/cen_lef.gif" width="16" height="11"></td>
          <td align="center" valign="middle" bgcolor="#FFFFFF">

                <!-- Debut du content de la table fancy round corner -->
                <table width="576" border="0" cellspacing="0" cellpadding="0" class="border" >
                  <tr >
                    <td rowspan="2" valign="top"><img src="/fr/images/necrologies/<?php  echo utf8_encode($row['photo']); ?>" alt="photo" /><br><a href="necrologies_print.php?id=<?php echo $row[id]; ?>" target="_blank"><img src="/fr/images/cnq/imprimable.gif" border="0" width="150" height="50"></a></td>
                    <td width="200" bgcolor="#DFEFFF" class="borderbas" style="border-left: 1px solid #000000; border-right: 1px solid #000000"><center><?php echo nl2br(mb_convert_encoding($row['nom'], "UTF-8", "Windows-1252")); ?></center></td>
                    <td bgcolor="#DFEFFF" class="borderbas">
              <center>
                      <strong>
                      <?php
            $maison = $row[maison];         
            if ($maison == "N/D") {
                echo "(information non disponible)"; 
            } else { 
                if (substr($maison, 0, 6) == "La dir") {
                    echo utf8_encode($maison);
                } else {
                    echo  "La direction des fun&eacute;railles a &eacute;t&eacute; confi&eacute;e &agrave;/aux <br>";
                    echo utf8_encode($maison);  
                }
            }
            ?>
            </strong></center></td>
                  </tr>
                  <tr>
                    <td style="border-left: 1px solid #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small;" colspan="2"><div class="padding" align="left"><?php echo nl2br(mb_convert_encoding($row['description'], "UTF-8", "Windows-1252")); ?></div></td>
                  </tr>
                </table>
            <!-- Fin du content de la table fancy round corner -->

          </td>
          <td width="24" background="/fr/images/roundtable/cen_rig.gif"><img src="/fr/images/roundtable/cen_rig.gif" width="24" height="11"></td>
        </tr>
        <tr>
          <td width="16" height="16"><img src="/fr/images/roundtable/bot_lef.gif" width="16" height="16"></td>
          <td height="16" background="/fr/images/roundtable/bot_mid.gif"><img src="/fr/images/roundtable/bot_mid.gif" width="16" height="16"></td>
          <td width="24" height="16"><img src="/fr/images/roundtable/bot_rig.gif" width="24" height="16"></td>
        </tr>
      </table>
    </div>
    <!-- Fin de la table fancy round corner -->

    <!--[if IE 8]>
   <style type="text/css">
        .tb{
        float:left;
        align:left;
        width:550px;
        scrolling-horizontal:none;
        }
    </style>
 <![endif]-->
     <!--[if IE 7]>
   <style type="text/css">
        .tb{
        float:left;
        align:left;
        width:550px;
        scrolling-horizontal:none;
        }
    </style>
 <![endif]-->
     <!--[if IE 6]>
   <style type="text/css">
        .tb{
        float:left;
        align:left;
        width:550px;
        scrolling-horizontal:none;
        }
    </style>
 <![endif]-->

    <br /><br />  
    <?php
    }
}
?>

<?php
// close la connection
mysql_close($connection); 
?>

1 个答案:

答案 0 :(得分:1)

目标应命名为框架或窗口;旧浏览器不使用框架的ID。所以改变:

<iframe id="frame" ...

<iframe name="frame" id="frame" ...