zoukankan      html  css  js  c++  java
  • Online_ChatRomm

     $(document).ready(function() {
            var timeid = null;
            timeid = setInterval('counter()', 5000);
        }).keydown(function(event) {
        var key = window.event ? event.keyCode : event.which;
        if ((key.toString() == "13") && (event.ctrlKey)) {
            sendMsg();
        }
        });
        function counter() {
            $.ajax({
                url: "BaseAjaxAppliction/newmsg.ashx",
                type: "get",
                dataType: "html",
                data: "myId=<%= MyId %>&friendId=<%= FriendId %>",
                success: function(msg) {
                    if (msg != "0") {
                        $("#body").append(msg);
                    }
                }
            });
            setTimeout('scrollDiv()', 100);
        }
        function sendMsg() {
            if ($("#content").val() == "") {
                $("#error").html("<span style=\"font-color:red;\">发送消息不能为空!</span>");
                return false;
            }
            $.get("BaseAjaxAppliction/newmsg.ashx", { body: $("#content").val(), myId: "<%= MyId %>", friendId: "<%= FriendId %>" },
                    function(msg) {
                        if (msg == "1") {
                            var de = new Date();
                            $("#body").append("<ul><li>我  " + de.toLocaleString() + "</li><li>说:" + $("#content").val() + "</li></ul>");
                            $("#content").val("");
                        }
                        else {
                            $("#error").html("<span style=\"color:red;\">消息发送失败,请重发!</span>");
                            $("#content").val("");
                        }
                    });
                    setTimeout('scrollDiv()', 100);
        }
        function scrollDiv(){
            $("#bodys").scrollTop($("#body").height());
        }
  • 相关阅读:
    PAT甲级1018Public Bike Management
    PAT甲级1003Emergency
    android的AIDL
    View的滑动冲突和解决方案
    弹性滑动原理
    View的滑动原理和多种滑动方法
    Android的Activity的生命周期
    Android获取App版本号和版本名
    转:Android检查设备是否联网
    androidstudio实现增量更新步骤
  • 原文地址:https://www.cnblogs.com/Andon_liu/p/1340642.html
Copyright © 2011-2022 走看看