【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倒计时效果 >>>>>>>>>>>>>>>>>>>> ...
随机推荐
- window wamp下xhprof的安装使用,Graphviz配置
在新的工作安排下来前赶紧把手上工作优化下,本来是靠xdebug+grindview来的,不过还是麻烦,就换上这个轻量级的性能测试了.网上搜的大多都是lamp环境下的,wamp下的倒是不多,而且不好用, ...
- Effective C++ 读书总结
(中文第三版 侯捷 译) 这本书在C++领域也是大名鼎鼎,在微博看到有人说,如果以前学过C语言,那只需花一天时间把 Effective C++ 看一遍,然后再看 leveldb代码(http://t. ...
- z-index 解析
很多人对z-index的认识仅止于:z-index是控制元素在页面中的堆叠顺序,z-index值高的元素显示在z-index值低的前面.而其中的原因才很少有人去深究,直到自己在实际项目中碰到由于z-i ...
- Jekyll报'Tag was never closed'错误
使用jekyll的代码高亮功能.但是发现有时总是很恼人的出现错误,报告说'Tag was never closed'.可是我很确定的关闭了标签啊,真是令人恼怒啊.解决方案式什么哪?如果你对此有兴趣,请 ...
- Scope and Namespace
Python基础-作用域和命名空间(Scope and Namespace) 在Python中,对象是独立的,不同作用域中的不同名字都可以被绑定在同一个对象上,当然对这个对象的修改会影响所有的引用.赋 ...
- No object in the CompoundRoot has a publicly accessible property named
No object in the CompoundRoot has a publicly accessible property named 'typeid' (no setter could be ...
- SQL Server中的高可用性1
SQL Server中的高可用性(1)----高可用性概览 自从SQL Server 2005以来,微软已经提供了多种高可用性技术来减少宕机时间和增加对业务数据的保护,而随着SQL Server ...
- Sqlite in Android
在Android上保存本地数据有三种方式,SharedPreferences.Files和Sqlite.SharedPreferences主要是用来保存键值对形式的程序配置信息,与ini.proper ...
- TOGAF架构内容框架之内容元模型(下)
TOGAF架构内容框架之内容元模型(下) 2.2 治理扩展(Governance Extensions) 治理扩展元模型内容 治理扩展部分的意图在于引入额外的,并且与支持运营治理的目标和业务服务相关的 ...
- LearnCpp.com
LearnCpp.com is a totally free website devoted to teaching you to program in C++. Whether you’ve had ...