网页常用特效整理
1.节日倒计时
<Script Language="javascript">
var timedate= new Date("October 1,2002");
var times="国庆节";
var now = new Date();
var date = timedate.getTime() - now.getTime();
var time = Math.floor(date / (1000 * 60 * 60 * 24));
if (time >= 0)
document.write("现在离"+times+"还有: "+time +"天")</Script>
2.单击按钮打印出当前页
<Script Language="javascript">
<!-- Begin
if (window.print) {
document.write('<form>'
+ '<input type=button name=print value="打印本页" '
+ 'onClick="javascript:window.print()"></form>');
}
// End -->
</Script>
3.单击按钮‘另存为’当前页
<input type="button" name="Button" value="保存本页"
onClick="document.all.button.ExecWB(4,1)">
<object id="button"
width=0
height=0
classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
<embed width="0" height="0"></embed>
</object>
4.显示系统当前日期
<script language=javascript>
today=new Date();
function date(){
this.length=date.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=date.arguments[i] }
var d=new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
document.write(
"<font color=##000000 style='font-size:9pt;font-family: 宋体'> ",
today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",
d[today.getDay()+1],"</font>" );
</script>
<Script Language="javascript">
<!--
var text=""; day = new Date( ); time = day.getHours( );
if (( time>=0) && (time < 7 ))
text="夜猫子,要注意身体哦! "
if (( time >= 7 ) && (time < 12))
text="今天的阳光真灿烂啊,你那个朋友呢?"
if (( time >= 12) && (time < 14))
text="午休时间。您要保持睡眠哦!"
if (( time >=14) && (time < 18))
text="祝您下午工作愉快! "
if ((time >= 18) && (time <= 22))
text="您又来了,可别和MM聊太久哦!"
if ((time >= 22) && (time < 24))
text="您应该休息了!"
document.write(text)
//--->
</Script>