Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function submitChat() {
- if(form1.msg.value == '') {
- alert("Enter your message!!!");
- return;
- }
- var msg = form1.msg.value;
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.onreadystatechange = function() {
- if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
- document.getElementById('chatlogs').innerHTML = xmlhttp.responseText;
- }
- }
- xmlhttp.open('GET','insert.php?msg='+msg,true);
- xmlhttp.send();
- }
- //////////////COMANDO PARA AUTO SCROLL//////////////////////
- ////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////
- function scroll(){
- window.setInterval(function() {
- var elem = document.getElementById('chatlogs');
- elem.scrollTop = elem.scrollHeight;
- }, 500);
- }
- ////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////
- $(document).ready(function(e){
- $.ajaxSetup({
- cache: false
- });
- setInterval( function(){ $('#chatlogs').load('logs.php'); }, 2000 );
- });
- </script>
- </head>
- <body style="background:rgb(20, 20, 20); color: orange;">
- <form name="form1">
- Seu NickName: <b><?php echo $_SESSION['username'] ." "; ?><a href="logout.php">SAIR da Conta</a><br /><br /></b> <br />
- <br />
- <div id="chatlogs" class="area"style="background:rgb(1, 1, 1);width: 100%; height: 500px; overflow:auto; margin-bottom: 20px; border-radius: 10px;">
- LOADING CHATLOG...
- </div>
- <textarea name="msg" style="background:rgb(38, 38, 38);color: orange; resize:none; border: none; border-radius: 10px; width: 90%; height: 50px;"></textarea>
- //////////////ONCLICK CHAMANDO A FUNCAO/////////////////////
- ////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////
- <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 />
- ////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement