Advertisement
Guest User

Untitled

a guest
May 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. <script>
  2.  
  3. function submitChat() {
  4. if(form1.msg.value == '') {
  5. alert("Enter your message!!!");
  6. return;
  7. }
  8. var msg = form1.msg.value;
  9. var xmlhttp = new XMLHttpRequest();
  10.  
  11. xmlhttp.onreadystatechange = function() {
  12. if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  13. document.getElementById('chatlogs').innerHTML = xmlhttp.responseText;
  14. }
  15. }
  16.  
  17. xmlhttp.open('GET','insert.php?msg='+msg,true);
  18. xmlhttp.send();
  19.  
  20. }
  21.  
  22.  
  23. //////////////COMANDO PARA AUTO SCROLL//////////////////////
  24. ////////////////////////////////////////////////////////////
  25. ////////////////////////////////////////////////////////////
  26. function scroll(){
  27. window.setInterval(function() {
  28. var elem = document.getElementById('chatlogs');
  29. elem.scrollTop = elem.scrollHeight;
  30. }, 500);
  31. }
  32. ////////////////////////////////////////////////////////////
  33. ////////////////////////////////////////////////////////////
  34. ////////////////////////////////////////////////////////////
  35. $(document).ready(function(e){
  36. $.ajaxSetup({
  37. cache: false
  38. });
  39. setInterval( function(){ $('#chatlogs').load('logs.php'); }, 2000 );
  40. });
  41.  
  42. </script>
  43.  
  44.  
  45. </head>
  46. <body style="background:rgb(20, 20, 20); color: orange;">
  47. <form name="form1">
  48. Seu NickName: <b><?php echo $_SESSION['username'] ." "; ?><a href="logout.php">SAIR da Conta</a><br /><br /></b> <br />
  49. <br />
  50.  
  51.  
  52.  
  53.  
  54.  
  55. <div id="chatlogs" class="area"style="background:rgb(1, 1, 1);width: 100%; height: 500px; overflow:auto; margin-bottom: 20px; border-radius: 10px;">
  56. LOADING CHATLOG...
  57. </div>
  58. <textarea name="msg" style="background:rgb(38, 38, 38);color: orange; resize:none; border: none; border-radius: 10px; width: 90%; height: 50px;"></textarea>
  59.  
  60.  
  61. //////////////ONCLICK CHAMANDO A FUNCAO/////////////////////
  62. ////////////////////////////////////////////////////////////
  63. ////////////////////////////////////////////////////////////
  64. <a href="#" onclick="submitChat();scroll();" style="color: rgb(0, 0, 0); font-family:'Arial Black'; text-decoration: none;background:orange; border-radius:10px;position:relative; top:-20;padding-top: 15px;padding-right: 25px;padding-bottom: 15px;padding-left: 25px;">Enviar</a><br /><br />
  65. ////////////////////////////////////////////////////////////
  66. ////////////////////////////////////////////////////////////
  67. ////////////////////////////////////////////////////////////
  68. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement