Internet Explorer在提交后更新html表单时显示闪烁效果

Internet Explorer在提交后更新html表单时显示闪烁效果,html,forms,Html,Forms,我有以下html/php/javascript代码: <?php $textBox1 = $_POST["textBox1"]; ?> <html> <head> </head> <body> <table border="0" cellpadding="2" cellspacing="2" align="center" bgcolor="#996ad6"> <form method="post" actio

我有以下html/php/javascript代码:

<?php
$textBox1 = $_POST["textBox1"];
?> 

<html>
<head>
</head>

<body>
<table border="0" cellpadding="2" cellspacing="2" align="center"  bgcolor="#996ad6">

<form method="post" action="<?php echo $PHP_SELF;?>" name="form1">
    <thead>
    <tr><th> Title </th></tr>
    </thead>
    <tbody>
        <tr>
            <td align="left">
                <textarea rows="8" cols="35" name="textBox1" textAlign="left" onKeyUp="changeVal()"><?php
                if (isset($_POST['textBox1'])) {
                    echo $textBox1;
                }
                ?></textarea><br />
            </td>

            <td align="left">
                <textarea rows="8" cols="35" name="textBox2" wrap="physical" align="left"><?php
                    if (isset($_POST['textBox1'])) {
                        echo "hello ".$textBox1;
                    }
                    ?></textarea><br />
            </td>
        </tr>
    </tbody>
    <script type="text/javascript" language="JavaScript">
    s1 = new String(form1.textBox1.value)
    var timer;

    function changeVal() {
        stoper();
        timer = setTimeout ( "document.form1.submit()", 800 ); 
    }

    function stoper() {
        clearTimeout(timer);
    }

    </script>
</form>
</table>

</body>
</html>


通过浏览器提交时,页面将重新加载。Chrome和Firefox的重画速度足够快,以至于你没有注意到重装,但IE似乎没有


为了避免重新加载的闪烁,您可能必须使用javascript
httpRequest
来发布表单值,并保持两个
textarea
同步。

这看起来像是在发布表单,如果用户键入任何内容并停止键入超过8秒,则重新加载整个页面

我可以看出这会导致页面闪烁。事实上,我很惊讶你没有遇到比这更糟糕的问题——我还希望它在刷新页面时会失去表单字段的焦点和位置,这会给用户带来问题(或者至少是混乱)

一个更好的解决方案是使用Ajax方法实现它,它允许您通过Javascript提交和接收数据,而无需刷新页面。您可能需要阅读
httpRequest
,这是您将在Javascript中使用的对象。但是,没有必要重新发明轮子,因为有许多JS库可以为您完成所有的艰苦工作。最著名的是JQuery,但还有很多其他的

顺便说一下(离题,但值得一提):

  • $PHP\u SELF
    已被弃用。您应该改用
    $\u服务器['PHP\u SELF']

  • HTML规范声明
    部分不能为空。至少,它必须包含一个


  • 如果这是一个浏览器问题,那么php代码不应该是相关的。请显示导致问题的输出html文件,如果可能,请尽可能减少该文件,同时仍导致闪烁。