点击显示与数据库一起输入的代码,而不使用iframe(就像当我们发布新闻时,它出现在facebook中)


onclick display the code entered along with database without using iframe( just like when we post a news it appears in facebook)

我想显示的内容就像在facebook。但我不明白。我用的是框架。有人能帮我这个不用iframe。我想让它独立。就像如果user1发布它必须与user2分开…但我没有得到它使用iframe,我只是得到一个换行…我在这里通过附加两个图像的想法缘故facebook布局这就是我的结局。如果你能解决……提前感谢,至少工作界面会有帮助

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
<html> 
<body>
<div id = "midle"> 
<div id="posts" > 
<h1>WHAT'S UP?</h1> 
<tr> <form method="POST" action="tryy.php" target="iframe_a" > 
<textarea name="post" rows="5" cols=110" target="iframe_a" ></textarea> 
<td><input id="button" type="submit" name="submit" value="POST" ></td> 
</form> 
<iframe width="100%" height="590" src="tryy.php" name="iframe_a"></iframe> 
</div> 
</div> 
</html> 

可以使用ajax。(用id为"status"的div替换iframe)

<div id="status"></div>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
    $.get(
       'tryy.php',
       function(response){
          $("#status").html(response);
       }
    );
</script>

插入到您的示例中:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
<html> 
<head>
<style>
  #status {
    background:#555;
    width: 100%;
    height: 590px;
  }
  </style>
</head>
<body>
  <div id="midle">
    <div id="posts">
      <h1>WHAT'S UP?</h1>
      <tr>
        <form method="POST" action="tryy.php" target="iframe_a">
          <textarea name="post" id="statusBox" rows="5" cols=110  target="iframe_a " ></textarea> 
<td><input id="button" type="submit"  name="submit " value="POST " ></td> 
</form> 
<div id="status"></div>
</div> 
</div>
<script src="https://code.jquery.com/jquery-1.12.4.min.js "></script>
<script>
function updateStatusList(){
  $.get(
    'tryy.php',
    function(response){
      $("#status").html(response);
    }
  );
}
$("#button").click(function(e) {
    e.preventDefault();
    updateStatusList();
    return false;
});
$("#statusBox").keydown(function(e) {
  if(e.keyCode == 13){ // when return was pressed
    updateStatusList();
  }
});
</script>
</body>
</html>
PS:

既然你是新人,给你一些提示:

  • 应该使用相反。
  • 使用结束符标签;)
  • 不要在没有table元素的情况下使用td, tr元素(实际上你根本不应该使用table进行布局)