一个每日一贴的小东西
来源:互联网 发布:java工程师证书有用么 编辑:程序博客网 时间:2024/06/10 20:16
想做一个类似于很多程序中的那个tips of day的东西
用到了javascript,自己写了一个
实现了自动翻滚的功能
想加上层拖动的功能
到网上搜了一下,很多的代码
但是发现质量不一
偶然的来到风微柳细的blog中发现了很好的代码
但是很多看不懂
比如window.event,setCapture,CaptureEvents,releaseCapture
在js的手册中也查不到结果,dhtml手册中也搜索不到
一时间没有了头脑
把代码贴出来
那位知道的,教教我啦:)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="utf-8">
<head>
<title>Script特效--每日一贴!</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Language" content="utf-8" />
<meta content="all" name="robots" />
<meta name="author" content="alvar" />
<meta name="Copyright" content="alvar" />
<meta name="Description" content="alvar" />
<meta content="javascript" name="keywords" />
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<style type="text/css">
<!--
#container {
position:absolute;
top:100px;left:400px;
background:#666;
border:1px dotted #000;
}
#header{
width:250px;
height:25px;
padding:0px;
font-family:sans-serif;
font-size:12px;
line-height:25px;
color:#fff;
overflow:hidden;
cursor:move;
text-align:right;
}
#close{
position:relative;
right:0px;
top:0px;
padding-right:5px;
cursor:hand;
}
.p1{
float:left;
padding-left:5px;
}
#content{
width:250px;
height:125px;
background:#666;
border-top:1px dotted #fff;
}
#duk{
font:16px Impact, sans-serif;
color:#fff;
margin:5px 15px;
}
#message{
color:#fff;
margin:0 5px 5px 20px;
}
#bottom{
width:250px;
height:25px;
padding:0px;
font-family:sans-serif;
font-size:12px;
line-height:25px;
color:#fff;
overflow:hidden;
text-align:left;
border-top:1px dotted #fff;
}
#num{
margin:0 5px;
}
#next{
margin:0 5px;
cursor:hand;
}
//-->
</style>
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/ie.css" />
<![endif]-->
<script type="text/javascript" language="javascript">
var i=0;
var timer1
var msg=new Array();
msg[0]="Hello world!";
msg[1]="I am a teen!";
msg[2]="I Love Computer Technology!";
msg[3]="I Love This Game!";
msg[4]="About FireFox's Browse problem, a headache enn";
function setstatus(){
num.innerText=(i+1)+"/"+msg.length;
message.innerText=msg[i];
}
function nextmsg(){
num.innerText="";
num.innerText=(i+1)+"/"+msg.length;
message.innerText=msg[i];
//alert(i);
i++;
if((i+1)>msg.length){
i=0;}
}
function checkon(){
//alert(ckauto.checked);
if(ckauto.checked==true){
nextmsg();
setTimeout("checkon()",2000);
}else{
clearTimeout(timer1);
}
}
function closewindow(){
document.getElementById("container").style.display='none';
}
function drag(o){
o.onmousedown=function(a){
var d=document;if(!a)a=window.event;
var x=a.layerX?a.layerX:a.offsetX,y=a.layerY?a.layerY:a.offsetY;
if(o.setCapture)
o.setCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
d.onmousemove=function(a){
if(!a)a=window.event;
if(!a.pageX)a.pageX=a.clientX;
if(!a.pageY)a.pageY=a.clientY;
var tx=a.pageX-x,ty=a.pageY-y;
o.style.left=tx;
o.style.top=ty;
};
d.onmouseup=function(){
if(o.releaseCapture)
o.releaseCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
d.onmousemove=null;
d.onmouseup=null;
};
};
}
</script>
</head>
<body id="home" onload="javascript:setstatus();">
<div id="wrap">
<div id="content">
<div id="container">
<div id="header" onclick="drag(document.getElementById('header'))"><p class="p1">Tip of the day!</p>
<span id="close" onclick="closewindow()">Close</span>
</div>
<div id="content">
<p><span id="duk">Do u know......</span></p>
<p id="message"><span></span></p>
</div>
<div id="bottom">
<span id="num"></span>
<span id="next" onclick="nextmsg();">Next</span>
<span id="auto"><input id="ckauto" type="checkbox" onclick="checkon();" >Auto</span>
</div>
</div>
</div>
</div>
</body>
</html>
- 一个每日一贴的小东西
- 贴一个 自己写的小东西....
- 批处理的一个小东西
- 一个未完成的小东西
- 一个小东西
- CSAPP中一个有意思的小东西
- 奉献给各位一个小东西:class Gotter(一)
- 每日一首古诗, 每日一个桌面壁纸
- 小东西总结(一)
- 一个关于日期选择的很实用的小东西
- **一个好幼稚的javascript变量加减的小东西**
- 刚接触FLASH时做的一个小东西
- jQuery实现了一个拖拽小东西的程序
- 正在写一个可以缩放移动地图的小东西
- 黑马程序员 做完一个小东西的一些想法
- 研一暑假没有回家,做的第一个小东西
- 【敏捷开发每日一贴】一个网上书店的实例化需求例子
- 每日一个OpenGL API (一)
- 网址
- 网址
- 网址
- VisualStudio.NET已检测到指定的Web服务器运行的不是ASP.NET1.1版的解决办法
- [网摘]常用编解码介绍
- 一个每日一贴的小东西
- 总结-前言
- libstdc++.so.5解决方法
- 在LINUX中使用外设方法
- Compiling Your Application with the Microsoft Layer for Unicode
- 兼职项目总结
- 跑步
- 如何解析网页源代码
- 《生日——我能否祝自己快乐》