哪位好心人能告诉我页面上的钟表功能是怎么实现的? 我目前的想法是:获取当前的时间放到页面上,可是需要刷新才能使时间更新。请问各位有什么办法不用刷新时间的秒数会自动增加的? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 那两个不会啊!暂时只会java基础。用纯java代码能写出来吗?谢谢二位 不用刷新页面 用线程的sleep()来达到刷新效果 比如在循环里 每sleep(1000)重新获取当前时间 <script> function tick() { var hours, minutes, seconds, xfile; var intHours, intMinutes, intSeconds; var today; today = new Date(); intHours = today.getHours(); intMinutes = today.getMinutes(); intSeconds = today.getSeconds(); if (intHours == 0) { hours = "12:"; xfile = "午夜"; } else if (intHours < 12) { hours = intHours+":"; xfile = "上午"; } else if (intHours == 12) { hours = "12:"; xfile = "正午"; } else { intHours = intHours - 12 hours = intHours + ":"; xfile = "下午"; } if (intMinutes < 10) { minutes = "0"+intMinutes+":"; } else { minutes = intMinutes+":"; } if (intSeconds < 10) { seconds = "0"+intSeconds+" "; } else { seconds = intSeconds+" "; } timeString = xfile+hours+minutes+seconds; document.getElementById("t").innerHTML=timeString window.setTimeout("tick();", 1000); } window.onload=tick </script> <div id="t"></div> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <META content="MSHTML 6.00.6000.16414" name=GENERATOR></HEAD> <BODY> <DIV style="LEFT: 155px; WIDTH: 400px; ZOOM: 1; POSITION: absolute; TOP: 133px; HEIGHT: 300px"> <DIV id=bg style="LEFT: -22px; WIDTH: 150px; ZOOM: 1.5; POSITION: absolute; TOP: -57px; HEIGHT: 150px"><IMG style="Z-INDEX: 22; WIDTH: 129px; HEIGHT: 129px" src="/upload/novelty.gif"> </DIV> <DIV id=h style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px"><IMG style="Z-INDEX: 22; WIDTH: 129px; HEIGHT: 129px" src="/upload/novelty_h.gif"> </DIV> <DIV id=m style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px"><IMG style="Z-INDEX: 22; WIDTH: 129px; HEIGHT: 129px" src="/upload/novelty_m.gif"> </DIV> <DIV id=s style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px"><IMG style="Z-INDEX: 22; WIDTH: 129px; HEIGHT: 129px" src="/upload/novelty_s.gif"> </DIV> <DIV id=dot style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px"><IMG style="Z-INDEX: 22; WIDTH: 129px; HEIGHT: 129px" src="/upload/novelty_dot.gif"> </DIV> <DIV> <SCRIPT> //oObj input requires that a matrix filter be applied. //deg input defines the requested angle of rotation. var deg2radians = Math.PI * 2 / 360; function MatrixFilter(obj) { if(!obj.filters)return; //alert(obj.filters.item(0)); var Matrix; for(p in obj.filters) { if(p=="DXImageTransform.Microsoft.Matrix")Matrix=obj.filters["DXImageTransform.Microsoft.Matrix"]; } if(!Matrix) { obj.style.filter+="progid:DXImageTransform.Microsoft.Matrix()"; } Matrix=obj.filters["DXImageTransform.Microsoft.Matrix"]; this.equal=function(Matrix2D_x) { if(Matrix2D_x.M11)Matrix.M11 = Matrix2D_x.M11; if(Matrix2D_x.M12)Matrix.M12 = Matrix2D_x.M12; if(Matrix2D_x.M21)Matrix.M21 = Matrix2D_x.M21; if(Matrix2D_x.M22)Matrix.M22 = Matrix2D_x.M22; } if(arguments[1])this.equal(arguments[1]); this.Rotate=function(deg) { rad = deg * deg2radians; costheta = Math.cos(rad); sintheta = Math.sin(rad); var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); this.equal(Matrix2D.Mul(Matrix,d)); } this.RotateTo=function(deg) { rad = deg * deg2radians; costheta = Math.cos(rad); sintheta = Math.sin(rad); var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); this.equal(d); } this.RotateAt=function(deg,sx,sy) { rad = deg * deg2radians; costheta = Math.cos(rad); sintheta = Math.sin(rad); var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); var x=sx-Matrix.Dx; var y=sy-Matrix.Dy; this.MoveTo(x*costheta+y*sintheta-x,-x*sintheta+y*costheta-y); this.equal(Matrix2D.Mul(Matrix,d)); } this.RotateToAt=function(deg,sx,sy) { rad = deg * deg2radians; costheta = Math.cos(rad); sintheta = Math.sin(rad); var d=new Matrix2D(costheta,-sintheta,sintheta,costheta); var x=sx; var y=sy; this.MoveTo(x-(x*costheta-y*sintheta),-(x*sintheta+y*costheta-x)); this.equal(d); } this.MoveTo=function(sx,sy) { Matrix.Dx=sx; Matrix.Dy=sy; } this.toMatrix2D=function() { return new Matrix2D(Matrix.M11,Matrix.M12,Matrix.M21,Matrix.M22); } this.ZoomBy=function(sx,sy) { var d=new Matrix2D(sx,0,0,sy); this.equal(Matrix2D.Mul(Matrix,d)); } this.toString=function() { return ""+Matrix.M11+" "+Matrix.M12+"\n"+Matrix.M21+" "+Matrix.M22+"\n" } //Matrix.SizingMethod='clip to original'; //this.fnSetRotation(30); //alert(Matrix.M11); //alert(obj.filters["DXImageTransform.Microsoft.Matrix"]); } function Matrix2D() { this.M11 = arguments[0]||1; this.M12 = arguments[1]||0; this.M21 = arguments[2]||0; this.M22 = arguments[3]||1; this.Mul_Matrix2D=function(Matrix2D_b) { var r=new Matrix2D(); r=Matrix2D.Mul(this,Matrix2D_b); return r; } this.toString=function() { return ""+this.M11+" "+this.M12+"\n"+this.M21+" "+this.M22+"\n" } } Matrix2D.Mul=function(Matrix2D_a,Matrix2D_b) { var r=new Matrix2D(); r.M11=Matrix2D_a.M11*Matrix2D_b.M11+Matrix2D_a.M12*Matrix2D_b.M21; r.M12=Matrix2D_a.M11*Matrix2D_b.M12+Matrix2D_a.M12*Matrix2D_b.M22; r.M21=Matrix2D_a.M21*Matrix2D_b.M11+Matrix2D_a.M22*Matrix2D_b.M21; r.M22=Matrix2D_a.M21*Matrix2D_b.M12+Matrix2D_a.M22*Matrix2D_b.M22; return r; } var ms=new MatrixFilter(s); var mm=new MatrixFilter(m); var mh=new MatrixFilter(h); var i=1; setInterval("ms.RotateToAt((new Date()).getSeconds()*6+6,69,69)",500); setInterval("mm.RotateToAt((new Date()).getMinutes()*6+6,69,69)",500); setInterval("mh.RotateToAt(((new Date()).getHours()+(new Date()).getMinutes()/60)*30,69,69)",500); //mf.MoveTo(30,70); //mf.ZoomBy(1.5,1.5); //mf.ZoomBy(1.5,1.5); //alert(mf.toMatrix2D()); //alert(Matrix2D.Mul(m2d1,m2d2)); //fnSetRotation(oDiv.filters.item(0),30); </SCRIPT> </DIV></DIV></BODY></HTML> 该文章转载自脚本之家:http://www.jb51.net/html/200704/48/9330.htm 为什么Java的所有流中都没有长度和位置的方法? 树的构造与遍历,请各位大侠看看有几种解法? 如何将日期时间型转换为 YYYMMDDhhmmZZZ格式 跪求 内存管理探讨 java中2个数据的交换如何实现?? 最後10,請問怎麼得到一個文件(abc.doc)的最後修改日期 ,謝謝 问一条sql语句的问题。 如何把这个给"矩阵加括号"的程序做成通用程序?? 很纠结的问题——Java中的余数为什么可以为负? 紧急求救!!!!!!!请指教 关于web.xml问题
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = xfile+hours+minutes+seconds;
document.getElementById("t").innerHTML=timeString
window.setTimeout("tick();", 1000);
}
window.onload=tick
</script>
<div id="t"></div>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.6000.16414" name=GENERATOR></HEAD>
<BODY>
<DIV
style="LEFT: 155px; WIDTH: 400px; ZOOM: 1; POSITION: absolute; TOP: 133px; HEIGHT: 300px">
<DIV id=bg
style="LEFT: -22px; WIDTH: 150px; ZOOM: 1.5; POSITION: absolute; TOP: -57px; HEIGHT: 150px"><IMG
style="Z-INDEX: 22; WIDTH: 129px; HEIGHT: 129px" src="/upload/novelty.gif">
</DIV>
<DIV id=h
style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px"><IMG
style="Z-INDEX: 22; WIDTH: 129px; HEIGHT: 129px" src="/upload/novelty_h.gif">
</DIV>
<DIV id=m
style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px"><IMG
style="Z-INDEX: 22; WIDTH: 129px; HEIGHT: 129px" src="/upload/novelty_m.gif">
</DIV>
<DIV id=s
style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px"><IMG
style="Z-INDEX: 22; WIDTH: 129px; HEIGHT: 129px" src="/upload/novelty_s.gif">
</DIV>
<DIV id=dot
style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; WIDTH: 129px; PADDING-TOP: 5px; POSITION: absolute; HEIGHT: 129px"><IMG
style="Z-INDEX: 22; WIDTH: 129px; HEIGHT: 129px" src="/upload/novelty_dot.gif">
</DIV>
<DIV>
<SCRIPT>
//oObj input requires that a matrix filter be applied.
//deg input defines the requested angle of rotation.
var deg2radians = Math.PI * 2 / 360;
function MatrixFilter(obj)
{
if(!obj.filters)return;
//alert(obj.filters.item(0));
var Matrix;
for(p in obj.filters)
{
if(p=="DXImageTransform.Microsoft.Matrix")Matrix=obj.filters["DXImageTransform.Microsoft.Matrix"];
}
if(!Matrix)
{
obj.style.filter+="progid:DXImageTransform.Microsoft.Matrix()";
}
Matrix=obj.filters["DXImageTransform.Microsoft.Matrix"];
this.equal=function(Matrix2D_x)
{
if(Matrix2D_x.M11)Matrix.M11 = Matrix2D_x.M11;
if(Matrix2D_x.M12)Matrix.M12 = Matrix2D_x.M12;
if(Matrix2D_x.M21)Matrix.M21 = Matrix2D_x.M21;
if(Matrix2D_x.M22)Matrix.M22 = Matrix2D_x.M22;
}
if(arguments[1])this.equal(arguments[1]);
this.Rotate=function(deg)
{
rad = deg * deg2radians;
costheta = Math.cos(rad);
sintheta = Math.sin(rad);
var d=new Matrix2D(costheta,-sintheta,sintheta,costheta);
this.equal(Matrix2D.Mul(Matrix,d));
}
this.RotateTo=function(deg)
{
rad = deg * deg2radians;
costheta = Math.cos(rad);
sintheta = Math.sin(rad);
var d=new Matrix2D(costheta,-sintheta,sintheta,costheta);
this.equal(d);
}
this.RotateAt=function(deg,sx,sy)
{
rad = deg * deg2radians;
costheta = Math.cos(rad);
sintheta = Math.sin(rad);
var d=new Matrix2D(costheta,-sintheta,sintheta,costheta);
var x=sx-Matrix.Dx;
var y=sy-Matrix.Dy;
this.MoveTo(x*costheta+y*sintheta-x,-x*sintheta+y*costheta-y);
this.equal(Matrix2D.Mul(Matrix,d));
}
this.RotateToAt=function(deg,sx,sy)
{
rad = deg * deg2radians;
costheta = Math.cos(rad);
sintheta = Math.sin(rad);
var d=new Matrix2D(costheta,-sintheta,sintheta,costheta);
var x=sx;
var y=sy;
this.MoveTo(x-(x*costheta-y*sintheta),-(x*sintheta+y*costheta-x));
this.equal(d);
} this.MoveTo=function(sx,sy)
{
Matrix.Dx=sx;
Matrix.Dy=sy;
}
this.toMatrix2D=function()
{
return new Matrix2D(Matrix.M11,Matrix.M12,Matrix.M21,Matrix.M22);
}
this.ZoomBy=function(sx,sy)
{
var d=new Matrix2D(sx,0,0,sy);
this.equal(Matrix2D.Mul(Matrix,d));
}
this.toString=function()
{
return ""+Matrix.M11+" "+Matrix.M12+"\n"+Matrix.M21+" "+Matrix.M22+"\n"
}
//Matrix.SizingMethod='clip to original';
//this.fnSetRotation(30);
//alert(Matrix.M11);
//alert(obj.filters["DXImageTransform.Microsoft.Matrix"]);
}
function Matrix2D()
{
this.M11 = arguments[0]||1;
this.M12 = arguments[1]||0;
this.M21 = arguments[2]||0;
this.M22 = arguments[3]||1;
this.Mul_Matrix2D=function(Matrix2D_b)
{
var r=new Matrix2D();
r=Matrix2D.Mul(this,Matrix2D_b);
return r;
}
this.toString=function()
{
return ""+this.M11+" "+this.M12+"\n"+this.M21+" "+this.M22+"\n"
}
}
Matrix2D.Mul=function(Matrix2D_a,Matrix2D_b)
{
var r=new Matrix2D();
r.M11=Matrix2D_a.M11*Matrix2D_b.M11+Matrix2D_a.M12*Matrix2D_b.M21;
r.M12=Matrix2D_a.M11*Matrix2D_b.M12+Matrix2D_a.M12*Matrix2D_b.M22;
r.M21=Matrix2D_a.M21*Matrix2D_b.M11+Matrix2D_a.M22*Matrix2D_b.M21;
r.M22=Matrix2D_a.M21*Matrix2D_b.M12+Matrix2D_a.M22*Matrix2D_b.M22;
return r;
}
var ms=new MatrixFilter(s);
var mm=new MatrixFilter(m);
var mh=new MatrixFilter(h);
var i=1;
setInterval("ms.RotateToAt((new Date()).getSeconds()*6+6,69,69)",500);
setInterval("mm.RotateToAt((new Date()).getMinutes()*6+6,69,69)",500);
setInterval("mh.RotateToAt(((new Date()).getHours()+(new Date()).getMinutes()/60)*30,69,69)",500);
//mf.MoveTo(30,70);
//mf.ZoomBy(1.5,1.5);
//mf.ZoomBy(1.5,1.5);
//alert(mf.toMatrix2D()); //alert(Matrix2D.Mul(m2d1,m2d2));
//fnSetRotation(oDiv.filters.item(0),30);
</SCRIPT>
</DIV></DIV></BODY></HTML>
该文章转载自脚本之家:http://www.jb51.net/html/200704/48/9330.htm