Dzwebs.Net

撰写电脑技术杂文十余年

利用ASP.NET实现在线截图的功能之JS代码

Admin | 2014-10-22 8:43:20 | 被阅次数 | 4167

温馨提示!

如果未能解决您的问题,请点击搜索;登陆可复制文章,点击登陆

  想实现ASP.NET实现在线截图的功能,需要使用两部分代码,请注意查看相应文章。

  这里是JS代码。

  一、JS代码

  var x, y;
        var old_position = {};
        var offset = {};
        $(document).ready(hide);
        function hide() {
            $("#div_caijian").fadeTo("slow", 0.5);
            $("#div_caijian").mousedown(function (e) {
                 old_position = { X: e.clientX, Y: e.clientY };
                offset = $("#div_caijian").offset();
                $("#div_caijian").css({ "background-color": "White" });
                var x1 = e.clientX - offset.left;
                var y1 = e.clientY - offset.top;
                $("#div_caijian").mousemove(function (k) {
                    offset = $("#div_caijian").offset();
                    if ((k.clientX - x1 - 73) <= 0) {
                        k.clientX = 73 + x1;
                    }
                    if ((k.clientX - x1 - 73) >= 155) {
                        k.clientX = 155 + 73 + x1;
                    }
                    if ((k.clientY - y1 - 63) <= 0) {
                        k.clientY = 63 + y1;
                    }
                    if ((k.clientY - y1 - 63) >= 115) {
                        k.clientY = 115 + 63 + y1;
                    }
                    x = k.clientX - x1;
                    y = k.clientY - y1;
                    $("#div_caijian").css({
                        left: x,
                        top: y
                    });
                    var x2 = (offset.left - 73) / 155 * 100;
                    var y2 = (offset.top - 63) / 115 * 75;
                    $("#img_liulan").css({
                        left: 0 - x2,
                        top: 0 - y2
                    });
                    $("#txt_left").val(offset.left - 73);
                    $("#txt_top").val(offset.top - 63);
                });
                $("#div_caijian").mouseup(function (k) {
                    $("#div_caijian").css({ "background-color": "transparent" });
                    $("#div_caijian").unbind("mousemove");
                });
            });
            $(document).mouseup(function () {
                $("#div_caijian").css({ "background-color": "transparent" });
                $("#div_caijian").unbind("mousemove");
            });
        };


该杂文来自: 网站开发杂文

上一篇:获取随机时间的代码

下一篇:利用ASP.NET实现在线截图的功能之ASP.NET代码

网站备案号:

网站备案号:滇ICP备11001339号-7

版权属性:

Copyright 2007-2021-forever Inc. all Rights Reserved.

联系方式:

Email:dzwebs@126.com QQ:83539231 访问统计