js计时器 + asp 计时器

本文详细介绍了如何使用JS和ASP实现实时监控功能,并结合位置更新技术,通过设置定时器和确认对话框来开启监控并获取设备的经纬度信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

JS:

<script type="text/javascript">

        var counts = 0;
        function starts() {
            if (counts == 1) {
                alert('已经开启了实时监控!')
                return false;

            }
            if (confirm("确定开启实时监控?")) {
                setInterval("GetJSMapGps()", 15000); //15秒
                counts = 1;
                return true;

            }
            else return false;


        }
        function dw() {

            appletFrame.s_locationSet(124.805832, 46.571381);
        }

        function GetJSMapGps() {

            var gpsX;
            var gpsY;
            gpsX = window.document.getElementById("hdflog").value; //经度
            gpsY = window.document.getElementById("hdflag").value; //纬度
            if (gpsX != null && gpsX != "" & gpsY != null && gpsY != "") {
                appletFrame.s_locationSet(gpsX, gpsY);

            }

        }

       
    </script>

asp:

protected void Timer1_Tick(object sender, EventArgs e)
    {
        string id = ViewState["mobileid"].ToString();
        if (!string.IsNullOrEmpty(id))
        {
            DataTable dtGps = GBLL.GetList(" imei = '" + id + "' order by intime desc ").Tables[0];
            if (dtGps.Rows.Count > 0)
            {
                string lat  = dtGps.Rows[0]["lat"].ToString();
                string lon = dtGps.Rows[0]["lon"].ToString();
                hdflog.Value = lon;
                hdflag.Value = lat;
            }
        }
    }
    protected void timersWatch_Click(object sender, EventArgs e)
    {
        Timer1.Interval = 10 * 1000;//10秒 开启计时器
    }

 

转载于:https://www.cnblogs.com/smile-wei/p/3327778.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值