【JS】倒计时
描述:
先要链接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】倒计时的更多相关文章
- js倒计时-倒计输入的时间
计算指定时间到指定时间之间相差多少天.时.分.秒. 节日.活动.商城常用. 原理: 主要使用到时间戳,也就是从1970 年 1 月 1 日 到指定时间的毫秒数. 1. 求出毫秒差 :当两个时间直接进行 ...
- js 倒计时(可自定义时间)
<html> <head> <title>js 倒计时</title> </head> <body> <div> & ...
- js倒计时显示
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>j ...
- Js倒计时程序
Js倒计时程序 点击下载
- JS倒计时网页自动跳转代码
<title>JS倒计时网页自动跳转代码</title> <script language="JavaScript" type="text/ ...
- JS倒计时 代码
JS倒计时 代码 <div> <span id="KSD">3</span>天 <span id="KSH">1 ...
- js倒计时函数和(js禁用和恢复a标签的操作)
<script type="text/javascript"> /*获取手机号*/ var start_time=60; function get_phone_nums ...
- js 倒计时跳转
用js实现简单的倒计时结束页面跳转效果,主要用到setInterval()和clearInterval()方法,页面跳转使用window.location.href = " ".倒 ...
- 常见JS倒计时
https://www.jb51.net/Special/356.htm //JS倒计时 <button onclick="resetTime(60)">启动倒计时 ...
- 页面倒计时跳转页面效果,js倒计时效果
页面倒计时跳转页面效果,js倒计时效果 >>>>>>>>>>>>>>>>>>>> ...
随机推荐
- jQuery中的DOM操作《思维导图》
首先,是关于jQuery中的DOM操作的<思维导图>,请点击这里:jQuery中的DOM操作 列表框的左右选项移动 <html> <head> <title& ...
- [原]使用MachOView辅助破解AppStore应用
在破解iOS应用的过程中,需要经常使用 otool 开获取程序本身的信息(比如:是否启用了PIE),获取加密信息, 但是CLI的程序在直观性上还是不如GUI的, 下面描述使用MachOView来查看到 ...
- [RM 状态机详解2] RMAppAttempt状态机详解
摘要 本文详细描述RMAppAttempt状态机内的状态与其转换关系,分析的代码基于Apache社区Hadoop最新的2.3.0版本. RMAppAttempt状态机 在RM中,一个RMApp可能对于 ...
- 关于UITextfield弹出键盘解决方案
解决的问题:当你点击一个UITextfield时,不想让其弹出键盘,如果你觉得不就是取消其第一响应者嘛,resignRespond一下不就行了嘛,确实,如果你只是在其编辑完成后让其键盘消失,那这个就够 ...
- linux serial 登录 cubieboard
折腾半天linux下的putty,最后搞得实在没办法,放弃putty改用minicom 1. 先安装minicom sudo apt-get install minicom 2.配置com minic ...
- 继承control的自定义TextBox
继承control的自定义TextBox 下面来介绍一下本人写的一个自定义的textbox,首先说一下写这个控件遇到的几个难点:第一.关联输入法:第二.画字符串和焦点线 先随便上两张效果图吧: 下面这 ...
- MVVM1
silverlight的数据校验大体分成3种类型: 数据是非必填的但是需要满足相应数据格式的 数据是必填的且可能需要进行数据格式校验的 其他(如数据的联动校验) 以下的数据校验方式针对第二种: 在相应 ...
- Unable to start T-SQL Debugging. Could not connect to the computer ‘.’
Unable to start T-SQL Debugging. Could not connect to the computer ‘.’ 在Win7上面使用SSMS连接到SQL Server使用D ...
- 项目中出现黄色感叹号 教你去掉Myeclipse的黄色感叹号
点击Window>>Preferences>>General>>Editors>>Text Editors>>Annotations 选中右 ...
- VS2012下基于Glut OpenGL glEdgeFlag示例程序:
glEdgeFlag (GLboolean flag)表示一个顶点是否应该被认为是多边形的一条边界边的起点.flag为GL_TRUE后面的点都被认为是边界上的点,flag为GL_FALSE则之后的点不 ...