title: How do I prevent reload when a user is going to write something?
body: <p>My website has a simple messaging system where users write messages and the recipients answer back, which is defined as chatting.</p>
  
  <p>I'm using an HTML to keep the page refreshing until the person receives a new message.</p>
  
  <pre><code>&lt;meta http-equiv="refresh" content="15;URL=chat_5999468.php"/&gt;
  </code></pre>
  
  <p>It keeps refreshing the page in every 15 seconds, so if a new message intrudes, it pops up. <strong>BUT</strong> it reloads the page even whilst the recipient is typing.  </p>
  
  <p>How do I prevent this reload when a user is typing his message in jQuery?</p>
  
  <p><strong>Edit</strong>: Page HTML (Similar to this):</p>
  
  <pre><code>&lt;!DOCTYPE html&gt; &lt;head&gt; &lt;title&gt;Untitled&lt;/title&gt; &lt;meta charset="UTF-8"/&gt; &lt;meta http-equiv="refresh" content="15;URL=chat_5999468.php"/&gt; &lt;style&gt; #b { color: #000; } .chat-input input[type="text"] { width: 65%; height: 30px; border: 1px solid #999999; border-top-right-radius: 10px; border-bottom-left-radius: 15px; padding: 10px; color: #0084ff; margin-left: 5px; margin-top: 10px; margin-bottom: 10px; } input:focus,button:focus,input,button { outline: none!important; } .chat-input input[type="submit"] { color: #000; background: url(https://i.stack.imgur.com/NAjD2.jpg) no-repeat; height: 47px; width: 47px; border: none; } .chat77 ul{ list-style: none; margin: 0; padding: 0; } .chat77 ul li{ display:inline-block; clear: both; padding: 8px; border-radius: 30px; margin-bottom: 2px; font-family: Helvetica, Arial, sans-serif; } .message-2 { background: #eee; float: left; } .message-me { float: right; background: #0084ff; color: #fff; } .message-2 + .message-me{ border-bottom-right-radius: 5px; } .message-2 + .message-me{ border-top-right-radius: 5px; border-bottom-right-radius: 5px; } .message-me:last-of-type { border-bottom-right-radius: 30px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="chat-input"&gt;&lt;label&gt;&lt;form method="post" action="chat_5999468.php" &gt;&lt;input type="text" name="txt" placeholder="Write here..." /&gt;&lt;input type="submit" name="submit_msg" value="" /&gt;&lt;/form&gt;&lt;/label&gt;&lt;/div&gt;&lt;center&gt;&lt;div id="chat-status"&gt;Online Mark Zuckerberg | &lt;a href="chat_5999468.php"&gt;Refresh&lt;/a&gt;&lt;/div&gt;&lt;/center&gt;&lt;br /&gt;&lt;div class="chat77"&gt;&lt;ul&gt;&lt;script&gt;var book="Me: 3";if(book=="Me: 3" ){document.write("&lt;li class='message-me'&gt;3&lt;/li&gt;");}else{document.write("&lt;li class='message-2'&gt;&lt;a href='/profile_12.php?u=Mark+Zuckerberg' id='b' target='_top'&gt;3&lt;/a&gt;&lt;/li&gt;");}&lt;/script&gt;&lt;script&gt;var book="Mark Zuckerberg: 2";if(book=="Me: 2" ){document.write("&lt;li class='message-me'&gt;2&lt;/li&gt;");}else{document.write("&lt;li class='message-2'&gt;&lt;a href='/profile_12.php?u=Mark+Zuckerberg' id='b' target='_top'&gt;2&lt;/a&gt;&lt;/li&gt;");}&lt;/script&gt;&lt;script&gt;var book="Me: Message1";if(book=="Me: Message1" ){document.write("&lt;li class='message-me'&gt;Message1&lt;/li&gt;");}else{document.write("&lt;li class='message-2'&gt;&lt;a href='/profile_12.php?u=Mark+Zuckerberg' id='b' target='_top'&gt;Message1&lt;/a&gt;&lt;/li&gt;");}&lt;/script&gt;&lt;/ul&gt;&lt;/div&gt;&lt;br /&gt; &lt;/body&gt; &lt;/html&gt; 
  </code></pre>