js 几个常用程序
来源:互联网 发布:linux配置java环境变量 编辑:程序博客网 时间:2024/05/17 22:46
图片随机出现:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<style>
div{
position:absolute;}
</style>
<body>
<div id="imgs" width="130px" height="120px">
<img src="../../shixun练习/shixun/images/news_2.jpg"/>
</div>
</body>
<script language="javascript">
var img=document.getElementById("imgs");
var yan=true;
var w=document.documentElement.clientWidth-130,h=document.documentElement.clientHeight-120;
function suiji(){
if(q<0 || q>w) {
if(e<0 || e>h){
yan=false;
}
}else{
var q=parseInt(Math.random()*500);
var e=parseInt(Math.random()*1000);
img.style.top=q+"px";
img.style.left=e+"px";
}
setTimeout("suiji()","1000");
}
suiji();
</script>
</html>
倒计时
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
var maxtime = 60*60 //一个小时,按秒计算,自己调整!
function CountDown(){
if(maxtime>=0){
minutes = Math.floor(maxtime/60);
seconds = Math.floor(maxtime%60);
msg = "距离结束还有"+minutes+"分"+seconds+"秒";
document.getElementById("timer").innerHTML=msg;
if(maxtime == 5*60) alert('注意,还有5分钟!');
--maxtime;
}
else{
clearInterval(timer);
alert("时间到,结束!");
}
}
function start(){
timer=setInterval("CountDown()",1000);
}
</script>
<body>
<button onclick="start()">开始倒计时</button>
<div id="timer" style="color:red"></div>
</body>
</html>
随机抽奖
<html>
<title>随机抽奖程序</title>
<head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
var alldata = "ASP,PHP,AJAX,ASP.NET,CSHARP,VB.NET,DELPHI,VB,VC,JS"; //抽奖数据,以逗号分隔
var alldataarr = alldata.split(",") ;
var num = alldataarr.length-1 ;
var timer ;
function change(){
document.getElementById("oknum").value = alldataarr[GetRnd(0,num)];
}
function start(){
clearInterval(timer);
timer = setInterval('change()',46); //随机数据变换速度,越小变换的越快
}
function ok(){
clearInterval(timer);
}
function GetRnd(min,max){
return parseInt(Math.random()*(max-min+1));
}
</SCRIPT>
<input type="text" id="oknum" name="oknum" value="">
<button onclick="start()" accesskey="s">开始抽奖(<U>S</U>)</button>
<button onclick="ok()" accesskey="o">停止(<U>O</U>)</button>
</body>
</html>
- js 几个常用程序
- 几个常用的JS
- 几个常用js 函数!
- 几个常用的js
- 几个常用程序
- js几个常用的方法
- 几个常用的js函数
- 几个常用的JS代码
- JS 几个常用属性,方法
- 常用的几个JS验证函数
- Flash中常用的几个JS语句
- JS 中几个常用日期函数
- 几个常用的js字符串处理函数
- js 的几个常用的字符串函数
- js 常用到的几个数学函数
- 常用的几个JS验证函数
- 几个常用的自定义js方法
- JS数组的几个常用方法
- 字符识别OCR研究三 字符识别,字符区域定位 经验总结:
- 王雪红:执着科技 让HTC崛起
- 《算法导论》第6章 堆排序 (4)Young氏矩阵
- iphone UITextView 输入文字光标都从最初点开始
- 最短路径——Bellman_Ford算法
- js 几个常用程序
- 使用共享内存进行进程间通信
- 零基础学习Sencha Touch(资料和教程集合)
- Material Valuation 物料评估
- pureMVC
- 抽象类和接口的区别
- 职业测试~~
- 数据库中的null转换成其他
- API 编辑框常用消息