iframe标头位置

时间:2014-04-10 07:36:16

标签: javascript php jquery iframe drop-down-menu

我遇到iframe问题。我的第一个文件filtre.html包含iframe,其基本代码如下:

<iframe name="filtre_demo" src="http://localhost:8888/modules/filtredemo/filtre.php" scrolling="no" height="220" width="220" frameborder="no"></iframe>

此文件filtre.php是一个包含3个级别(PHP / MYSQL)的下拉动态列表。

Filtre.php这个文件实际上是一个动态下拉列表3级,可以在数据库中找到信息。提交发送到URL并且一切正常。

我的问题在于iframe。当我点击提交时,在220x220的这一部分找到了目标页面,而不是重新加载父页面。

我尝试了几种解决方案无济于事。这是我的php文件的一部分(我故意截断了几个部分),包括标题位置和表单:

     $ligne=mysql_fetch_assoc($rech_lien);
     $lien=$ligne['lien'];
     header('Location:'.$lien.'');

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
</head>
<body style="font-size: 75%; width: 210px;">

<form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post" id="chgcategories">

<fieldset style="border: 0px">
    <select name="modele" id="modele" onchange="submit();">
        <option value="-1">-Choisissez un modele-</option>
                <select name="sous_categorie" id="sous_categorie">
                    <option value="-1">-Sous-cat-</option>
                </select>
                <input type="hidden" name="nb_listes"  value="3" />
                <br /><br />
                <input type="submit" name="ok" id="ok2" value="Envoyer"/>
</form>

我也试过javascript但没有成功。在这个配置中,我删除了该行:

header('Location:'.$lien.'');

以下是标题中的javascript代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<script type="text/javascript">
parent.document.location.href="<?php echo $lien; ?>";
</script>
</head>
<body style="font-size: 75%; width: 210px;">

这种情况下的问题是文档加载循环。

无论如何,我被困住了,我事先感谢你的帮助。

文森特

2 个答案:

答案 0 :(得分:0)

如果我了解发生了什么,那么这些按钮是针对iframe的内容并在其中加载页面,而不是实际的窗口?如果是这种情况,请将target属性设置为_parent_top,并且该属性应定位到实际窗口。

答案 1 :(得分:0)

你可以尝试这个javascript代码:

<?php

/*-------Your Php Code-----*/

\\Replace this code @header(location)

echo "<script>";

echo "window.location='yourloation.php';";

echo "</script>";

/*-------Your Php Code-----*/

?>