Js 使用小技巧总结(1)

1.Js 的时间控制,小于初始时间,大于截止时间

   <script type="text/javascript">
        window.onload = GameOver;
        function GameOver() {
            var startDate = new Date("2016-10-01 00:00:00");
            var endDate = new Date("2016-10-08 00:00:00");
            var currentData = new Date();
            if (currentData < startDate || currentData > endDate) {
                window.location.href = _urlBase + "/Shake/ShakeExcept";
            }
        }
    </script>

2.Js  简单访问监控代码

var _urlBase = "";
$(function () {
    $.ajax({
        url: _urlBase+'/pv',
        data: { fromUrl: window.location.href },
        datatype: 'json',
        type: 'post'
    });
});

3.获取URL参数

  function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }

4. data-value='123'  获取

 $("#tcContent").data('value'),

posted @ 2016-09-21 10:32  李寒星  阅读(194)  评论(0编辑  收藏  举报