描述:

先要链接jquery.js,这样写法可以直接放JS文件运行。

//放在图片里定位的倒计时

//顶图里面定位才使用的代码
document.writeln("<style>");
document.writeln(" .top_div1{width:100%;overflow:hidden;margin:0 auto;text-align:center;}");
document.writeln(" .top_div2{");
document.writeln(" text-align:center;max-width:1600px;margin:0 auto;text-align:center;background: url(/images/headerPic.jpg) no-repeat center;height:200px;");
document.writeln(" } ");
document.writeln(" .top_div3{");
document.writeln(" height:100px;width:100px;position:absolute;right:245px;top:40px;float:right;");
document.writeln(" }");
document.writeln(" </style>");
document.writeln(" <div class=\"top_div1\">");
document.writeln(" <a href=\"/hd_tex.html\" onclick=\"gaPush(\'top_huodong_banner\'); _czc.push([\'_trackEvent\', \'swt\', \'top_huodong_banner\', \'top_huodong_banner\', 0, \'top_huodong_banner\']);\" target=\"_blank\">");
document.writeln(" <div class=\"top top_div2\">");
document.writeln(" <div id=\"div_dw\" class=\"top_div3\">");
document.writeln(" <div id=\"lastDays1\" style=\"color:red;font-size:95px;font-weight: bold;line-height:70px;height:70px;margin-top:5px;font-family:黑体\"></div>");
document.writeln(" <div style=\"font-size:10px;color:#000;margin-top:10px; margin-left:10px;\"><span id=\"lastHours1\">12</span>小时<span id=\"lastMin1\">23</span>分<span id=\"lastSecond1\">0</span>秒</div> ");
document.writeln(" </div>");
document.writeln(" </div>");
document.writeln(" </a>");
document.writeln(" </div>"); //以屏宽1424为准的计算
var juli = 245 + ($(window).width() - 1424)/2;
$("#div_dw").css("right",juli);
//顶图倒计时
function ShowTOPDown(year,month,day)
{
var now = new Date();
var endDate = new Date(year, month-1, day);
var leftTime=endDate.getTime()-now.getTime();
var leftsecond = parseInt(leftTime/1000);
//var day1=parseInt(leftsecond/(24*60*60*6));
var day1=Math.floor(leftsecond/(60*60*24));
var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
$("#lastDays1").html(day1);
$("#lastHours1").html(hour);
$("#lastMin1").html(minute);
$("#lastSecond1").html(second);
}
window.setInterval(function(){ShowTOPDown(2016,01,02);}, 1000);

【JS】倒计时的更多相关文章

  1. js倒计时-倒计输入的时间

    计算指定时间到指定时间之间相差多少天.时.分.秒. 节日.活动.商城常用. 原理: 主要使用到时间戳,也就是从1970 年 1 月 1 日 到指定时间的毫秒数. 1. 求出毫秒差 :当两个时间直接进行 ...

  2. js 倒计时(可自定义时间)

    <html> <head> <title>js 倒计时</title> </head> <body> <div> & ...

  3. js倒计时显示

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>j ...

  4. Js倒计时程序

    Js倒计时程序 点击下载

  5. JS倒计时网页自动跳转代码

    <title>JS倒计时网页自动跳转代码</title> <script language="JavaScript" type="text/ ...

  6. JS倒计时 代码

    JS倒计时 代码 <div> <span id="KSD">3</span>天 <span id="KSH">1 ...

  7. js倒计时函数和(js禁用和恢复a标签的操作)

    <script type="text/javascript"> /*获取手机号*/ var start_time=60; function get_phone_nums ...

  8. js 倒计时跳转

    用js实现简单的倒计时结束页面跳转效果,主要用到setInterval()和clearInterval()方法,页面跳转使用window.location.href = " ".倒 ...

  9. 常见JS倒计时

    https://www.jb51.net/Special/356.htm  //JS倒计时  <button onclick="resetTime(60)">启动倒计时 ...

  10. 页面倒计时跳转页面效果,js倒计时效果

    页面倒计时跳转页面效果,js倒计时效果 >>>>>>>>>>>>>>>>>>>> ...

随机推荐

  1. Oracle常用操作

      比较时间 select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss' ...

  2. QuickWebApi:使用Lambada方式,完成对WebApi的开发和调用。

    QuickWebApi 目的:使用Lambada方式,完成对WebApi的开发和调用. 缘由:为了解耦服务和展现,将越来越多的使用WebApi提供各种服务:随着服务的细化,WebApi的接口将越来越多 ...

  3. linux 之 getopt_long()

    文件 #include <getopt.h> 函数原型 int getopt_long(int argc, char * const argv[], const char *optstri ...

  4. SqlBulkCopy实现大容量数据快速插入数据库中

    一般情况下,我们手写sqlhelper类,在此类中定义一个数据插入到数据库的一个方法.将数据库连接密封在using()的语句中.using显示了Idispose接口.可以及时释放数据库连接资源.代码如 ...

  5. 淘宝ued - 前端智勇大闯关(第三季)答案(更新)

    淘宝ued - 前端智勇大闯关(第三季)答案(更新) 下午在微博上看到了淘宝智勇大闯关第三季的信息,感觉挺有意思的,于是就尝试做了下.附上题目地址: http://ued.campus.alibaba ...

  6. HDFS中文件的压缩与解压

    HDFS中文件的压缩与解压 文件的压缩有两大好处:1.可以减少存储文件所需要的磁盘空间:2.可以加速数据在网络和磁盘上的传输.尤其是在处理大数据时,这两大好处是相当重要的. 下面是一个使用gzip工具 ...

  7. 不再害羞,过程比结果更重要;分享一套 CodeSmit 代码生成模板。

    住博客园 5 年了,以前也发过一些博文,但都在 一天后 / 几周后 / 几年后 将它删了:因为感觉代码写得不好:不清晰或侵入太大,哪怕只有一句侵入. 可是最近重写一套 CodeSmith 代码生成模板 ...

  8. MacOSX64位机器上gcc编译32位x264静态库

    x264最新包地址:http://www.videolan.org/developers/x264.html 编译命令: ./configure --enable-static --host=i386 ...

  9. kuryr环境搭建

    前言 kuryr是docker和neutron结合的一个项目.docker自1.9之后,支持libnetwork的remote的driver,使得可以通过json rpc调用,为docker提供网络. ...

  10. InvocationHandler中invoke()方法的调用问题

    转InvocationHandler中invoke()方法的调用问题 Java中动态代理的实现,关键就是这两个东西:Proxy.InvocationHandler,下面从InvocationHandl ...