Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user = $_GET["user"];
- ?>
- <html>
- <head>
- <style>
- .display {
- background-color: #F0FFFF;
- width: 80%;
- position: relative;
- left: 10%;
- border: 1px solid black;
- height: 80%;
- }
- .tb {
- width:100%;
- height: 5%;
- }
- </style>
- </head>
- <body>
- <h1>Instant Messanger</h1>
- <div class="display">
- <p id="content"></p><br>
- </div>
- <div class="contentbar">
- <input class="tb" type="text" id="msg">
- <button onclick="send()">Send</button>
- </div>
- </body>
- </html>
- <script>
- function send() {
- var msg = document.getElementById("msg").value;
- var user = "<?php echo $user; ?>";
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.open("GET", "backend.php?mode=send&user=" + usr + "&msg=" + msg, true);
- xmlhttp.send();
- }
- function get() {
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.onreadystatechange = function() {
- if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
- document.getElementById("content").innerHTML = xmlhttp.responseText;
- }
- };
- xmlhttp.open("GET", "backend.php?mode=get", true);
- xmlhttp.send();
- }
- setInterval(get, 1000);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement