有一个页面是显示页面(index.php),别一窗口有一页面是添加内容页面(add.php),现在我添加内容保存到数据库中后通过什么代码能让index.php页面刷新,add.php页面关闭。高手指点一下。

解决方案 »

  1.   

    如果你是通过window.open打开的,可用window.opener.location.reload()来刷新,或者都是_self页面中显示的,只要你添加内容成功时,重新定向到显示页面就可以自己刷新了
      

  2.   

    header的前面不要有输出和错误,否则要则页面最顶端ob_start()
    也可以:echo '<script>location.href="index.php";</script>';这个就不会有以上问题了
      

  3.   

    http://topic.csdn.net/u/20100429/23/e37c47f5-3606-4512-98f2-060d840fe690.html这里有讨论,是你需要的么?不是通过php,js的,不过加上ajax与服务器端通讯也是容易的
      

  4.   

    不是window.open打开 的,打开的代码为:<a hre="add.php" target="_blank">添加内容</a>
      

  5.   

    这个你多看看dedecms 和phpcms 他们写的函数。
      

  6.   

    还是用window.open打开吧, target="_blank"打开的在关闭的时候有点问题
      

  7.   

    index.php
    ..................
    <html>
    <head>
    <title> 无标题文档 </title>
    <meta   http-equiv= "Content-Type "   content= "text/html;   charset=utf-8 ">
    <script language="javascript">
    function   openwin()
    {
      new_win = window.open('add.php','', 'height=300, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no'); 
      }
    function   closewin()
    {
    window.opener = "meizz"; //IE5.5+
    window.location.href = window.location.href;
    new_win.close(); 
      }
    </script>
    <input name="" type="button" onClick="closewin();" value="关闭add并刷新index">
    <input name="" type="button" onClick="openwin();" value="打开add页面">
    </body>
    </html>
     
    add.php
    ................
      

  8.   

    LZ为什么不用ajax呢。弹出一个层 来显示新增的内容,然后点击提交后,用js关闭即可,总是用jquery直接搞定,很方便的,最主要是用户体验好