1、数字时钟

  1.  
  2. 背景时钟[好大的钟][推荐][共1步]
  3.  
  4. ====1、以下是这个效果的全部代码。[最好从一个空页面开始]
  5.  
  6. <html>
  7. <head>
  8. <TITLE>背景时钟</TITLE>
  9. <script language=javaScript>
  10. <!--//
  11. function clockon() {
  12. thistime= new Date()
  13. var hours=thistime.getHours()
  14. var minutes=thistime.getMinutes()
  15. var seconds=thistime.getSeconds()
  16. if (eval(hours) <10) {hours="0"+hours}
  17. if (eval(minutes) < 10) {minutes="0"+minutes}
  18. if (seconds < 10) {seconds="0"+seconds}
  19. thistime = hours+":"+minutes+":"+seconds
  20. if(document.all) {
  21. bgclocknoshade.innerHTML=thistime
  22. bgclockshade.innerHTML=thistime
  23. }
  24. if(document.layers) {
  25. document.bgclockshade.document.write('<div id="bgclockshade" style="position:absolute;visibility:visible;font-family:Verdana;color:FFAAAAA;font-size:120px;top:10px;left:152px">'+thistime+'</div>')
  26. document.bgclocknoshade.document.write('<div id="bgclocknoshade" style="position:absolute;visibility:visible;font-family:Verdana;color:DDDDDD;font-size:120px;top:10px;left:150px">'+thistime+'</div>')
  27. document.close()
  28. }
  29. var timer=setTimeout("clockon()",200)
  30. }
  31. //-->
  32. </script>
  33. <link rel="stylesheet" href="../style.css"></head>
  34. <body onLoad="clockon()">
  35. <div id="bgclockshade" style="position:absolute;visibility:visible;font-family:Arial;color:FF8888;font-size:120px;top:102px;left:152px"></div>
  36. <div id="bgclocknoshade" style="position:absolute;visibility:visible;font-family:Arial;color:DDDDDD;font-size:120px;top:100px;left:150px"></div>
  37. <div id="mainbody" style="position:absolute; visibility:visible">
  38. </div>
  39. </body>
  40. </html>
  41. 说明:时钟显示的位置需要你修正TOP,LEFT参数来确定。TOP表示层距离显示器顶部的象素值,LEFT表示距离左侧的象素值。

2、永远居中的图片

  1.  
  2. 永远居中的背景图片[推荐][共1步][修改图片名称]
  3.  
  4. ====1、将以下代码加入HEML的<body></body>之间:
  5.  
  6. <STYLE TYPE="text/css">
  7. <!--
  8. BODY {background-image: URL(图片名称.gif);
  9. background-position: center;
  10. background-repeat: no-repeat;
  11. background-attachment: fixed;}
  12. -->
  13. </STYLE>

3、随机显示的背景图片

  1.  
  2. 随机显示的背景图片[想别人每次看你页面时背景都不一样吗?][共1步]
  3.  
  4. ====1、将以下代码加入HTML的<head></head>之间:
  5.  
  6. <script LANGUAGE="JavaScript">
  7. bg = new Array(2); //设定图片数量,如果图片数为3,这个参数就设为2,依次类推
  8. bg[0] = 'bg1.gif' //显示的图片路径,可用http://
  9. bg[1] = 'bg2.gif'
  10. bg[2] = 'bg3.gif'
  11. index = Math.floor(Math.random() * bg.length);
  12. document.write("<BODY BACKGROUND="+bg[index]+">");
  13. </script>

4、不断变换的背景颜色

  1.  
  2. 不停变换的背景颜色[共1步]
  3.  
  4. ====1、将以下代码加入HTML的<body></body>之间:
  5.  
  6. <body bgColor="#ffffff" onload="chgCol(); pingpong();">
  7. <script language="JavaScript">
  8. <!-- Hide from JavaScript-Impaired Browsers
  9. var pos = 10;
  10. function initArray() {
  11. this.length = initArray.arguments.length;
  12. for (var i = 0; i < this.length; i++) {
  13. this[i] = initArray.arguments[i];
  14. }
  15. }
  16. var col=new initArray("4b","5b","8b","8b");
  17. col[0] = "yellow";
  18. col[1] = "coral";
  19. col[2] = "orange";
  20. col[3] = "red";
  21. col[4] = "greenyellow";
  22. col[5] = "lime";
  23. col[6] = "turquoise";
  24. col[7] = "coral";
  25. col[8] = "blueviolet";
  26. col[9] = "violet";
  27. function chgCol() {
  28. pos++;
  29. if (pos<0||pos>9) {
  30. pos = 0;
  31. }
  32. document.bgColor = col[pos];
  33. setTimeout("chgCol()",5000);
  34. /* Change above set to every 10 seconds (1000 = 1 sec) If
  35. you wish to speed it up, lower the number. To slow it
  36. down, raise the number. */
  37. }
  38. var yourwords = "不斷變化背景色彩";var buffer1=" ";var buffer2=" ";var message1=buffer1+yourwords+buffer2;var dir = "left";var speed =150;function pingpong(){if (dir == "left") { message2=message1.substring(2,message1.length)+" "; window.status=message2; setTimeout("pingpong();",speed); message1=message2; if (message1.substring(0,1) == "*") dir="right"; }else { message2=" "+message1.substring(0,message1.length-2); window.status=message2; setTimeout("pingpong();",speed); message1=message2; if (message1.substring(message1.length-1,message1.length) == "*") dir="left"; }}// --></script>

5、背景颜色自己选

  1. 背景颜色自己选[推荐][共1步]
  2.  
  3. ====1、以下是这个效果的全部代码。[最好从一个空页面开始]
  4.  
  5. <html>
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=gb_2312-80">
  8. <title>新页面 </title>
  9. </head>
  10. <body>
  11. <script language="JavaScript">
  12. <!--
  13. done = 0;
  14. step = 4
  15. function anim(yp,yk)
  16. {
  17. if(document.layers) document.layers["napis"].top=yp;
  18. else document.all["napis"].style.top=yp;
  19. if(yp>yk) step = -4
  20. if(yp<60) step = 4
  21. setTimeout('anim('+(yp+step)+','+yk+')', 35);
  22. }
  23. function start()
  24. {
  25. if(done) return
  26. done = 1;
  27. if(navigator.appName=="Netscape") {
  28. document.napis.left=innerWidth/2 - 145;
  29. anim(60,innerHeight - 60)
  30. }
  31. else {
  32. napis.style.left=11;
  33. anim(60,document.body.offsetHeight - 60)
  34. }
  35. }
  36. //-->
  37. </script>
  38. <div id="napis"
  39. style="position: absolute;top: -50;
  40. color: #000000;font-family:宋体;font-size:9pt;">
  41. </div><script language="JavaScript">
  42. <!--
  43. setTimeout('start()',10);
  44. //-->
  45. </script>
  46. <script language="JavaScript">
  47. <!-- Begin
  48. function initArray() {
  49. for (var i = 0; i < initArray.arguments.length; i++) {
  50. this[i] = initArray.arguments[i];
  51. }
  52. this.length = initArray.arguments.length;
  53. }
  54. var colors = new initArray(
  55. "#000000","#0000FF","#80FFFF","#80FF80","#FFFF00","#FF8000","#FF00FF","#FF0000"
  56. );
  57. delay = 100
  58. link = 0;
  59. vlink = 0;
  60. function linkDance() {
  61. link = (link+1)%colors.length;
  62. vlink = (vlink+1)%colors.length;
  63. document.linkColor = colors[link];
  64. document.vlinkColor = colors[vlink];
  65. setTimeout("linkDance()",delay);
  66. }
  67. linkDance();
  68. // End -->
  69. </script>
  70. <script>
  71. function colors(c1){
  72. this.c1 = c1;
  73. }
  74. a00 = new colors("FFFBD0");
  75. a01 = new colors("FF0000");
  76. a02 = new colors("FF8080");
  77. a03 = new colors("FF8000");
  78. a04 = new colors("FFFF00");
  79. a05 = new colors("000080");
  80. a06 = new colors("0000FF");
  81. a07 = new colors("008000");
  82. a08 = new colors("00FF00");
  83. a09 = new colors("804000");
  84. a10 = new colors("808000");
  85. a11 = new colors("000000");
  86. a12 = new colors("FFFFFF");
  87. a13 = new colors("C0C0C0");
  88. a14 = new colors("408080");
  89. a15 = new colors("808080");
  90. a16 = new colors("D2BF51");
  91. a17 = new colors("44BBE8");
  92. a18 = new colors("C97AB9");
  93. a19 = new colors("A2C97A");
  94. a20 = new colors("804000");
  95. a21 = new colors("6AE6C4");
  96. a22 = new colors("33A3D1");
  97. a23 = new colors("6C9AEE");
  98. function changebg(type){
  99. scheme = type;
  100. document.bgColor = scheme.c1;
  101. timerID=setTimeout('document.bgColor = scheme.c2', document.selector.value * 10);
  102. }
  103. </script>
  104. <form NAME="selector">
  105. <p><input TYPE="button" onClick="changebg(a00)" style="background-color: rgb(255,251,208)"><input
  106. TYPE="button" onClick="changebg(a01)" style="background-color: rgb(255,0,0)"><input
  107. TYPE="button" onClick="changebg(a02)" style="background-color: rgb(255,128,128)"><input
  108. TYPE="button" onClick="changebg(a03)" style="background-color: rgb(255,128,0)"><input
  109. TYPE="button" onClick="changebg(a04)" style="background-color: rgb(255,255,0)"><input
  110. TYPE="button" onClick="changebg(a05)" style="background-color: rgb(0,0,128)"><input
  111. TYPE="button" onClick="changebg(a06)" style="background-color: rgb(0,0,255)"><input
  112. TYPE="button" onClick="changebg(a07)" style="background-color: rgb(0,128,0)"><input
  113. TYPE="button" onClick="changebg(a08)" style="background-color: rgb(0,255,0)"><input
  114. TYPE="button" onClick="changebg(a09)" style="background-color: rgb(128,0,0)"><input
  115. TYPE="button" onClick="changebg(a10)" style="background-color: rgb(128,128,0)"><input
  116. TYPE="button" onClick="changebg(a11)" style="background-color: rgb(0,0,0)"><input
  117. TYPE="button" onClick="changebg(a12)" style="background-color: rgb(255,255,255)"><input
  118. TYPE="button" onClick="changebg(a13)" style="background-color: rgb(192,192,192)"><input
  119. TYPE="button" onClick="changebg(a14)" style="background-color: rgb(64,128,128)"><input
  120. TYPE="button" onClick="changebg(a15)" style="background-color: rgb(128,128,128)"><input
  121. TYPE="button" onClick="changebg(a16)" style="background-color: rgb(210,191,81)"><input
  122. TYPE="button" onClick="changebg(a17)" style="background-color: rgb(68,187,232)"><input
  123. TYPE="button" onClick="changebg(a18)" style="background-color: rgb(201,122,185)"><input
  124. TYPE="button" onClick="changebg(a19)" style="background-color: rgb(162,201,122)"><input
  125. TYPE="button" onClick="changebg(a20)" style="background-color: rgb(106,230,196)"><input
  126. TYPE="button" onClick="changebg(a21)" style="background-color: rgb(194,219,185)"><input
  127. TYPE="button" onClick="changebg(a22)" style="background-color: rgb(51,163,209)"><input
  128. TYPE="button" onClick="changebg(a23)" style="background-color: rgb(108,154,238)"> </p>
  129. </form>
  130. </body>
  131. </html>

JavaScript特效源码(5、背景特效)的更多相关文章

  1. JavaScript特效源码(1、文字特效)

    注:本文以及以下关于Javascript特效源码都是分享自JavaScript源码大全. 1.逐隐逐现的的特效 逐隐逐现的文字特效[推荐使用][适用于IE4++] (修改显示的文字后根据说明进行共2步 ...

  2. 多种的android进度条的特效源码

    多种的android进度条的特效源码,这个源码是在源码天堂那个网站上转载过来的,我已经修改一部分了,感觉很实用的,大家可以学习一下吧,我就不上传源码了,大家可以直接到那个网站上下载吧. 源码天堂下载地 ...

  3. JavaScript特效源码(4、鼠标特效)

    1.鼠标感应--渐现特效 鼠标感应渐显图片[平时很模糊的图片鼠标一放上就显示清楚] [修改图片名称即可][共2步] ====1.将以下代码加入HTML的<head></head> ...

  4. 3D轮播切换特效 源码

    这个3D轮播切换特效是我2017年2月份写的 当初我 刚接触HTML不久,现在把源码分享给大家 源码的注释超级清楚 . <!-- 声明文档类型:html 作用:符合w3c统一标准规范 每个浏览器 ...

  5. 使用C#重写网上的60行 Javascript 俄罗斯方块源码 (带注释)

    在很久很久以前,就已经看过 60行Js的俄罗斯方块源码.无奈当时能力不够看明白,当时觉得就是个神作. 现在总算有空再看了,顺便用c#实现一遍(超过60行),顺道熟悉下Js API. 网上其他博客也有分 ...

  6. JavaScript特效源码(7、页面特效二)

    7.将站点加入频道栏 将站点加入频道栏[看详细说明] ====1.加入channel的方法:使用如下连接指向你的频道文件*.cdf. <a href="javascript:windo ...

  7. JavaScript特效源码(8、其他特效)

    1.中文日期 中文日期[无须修改][共1步]] ====1.将以下代码加入HEML的<body></body>之间 <script LANGUAGE="Java ...

  8. JavaScript特效源码(6、页面特效一)

    1.页面全屏 页面全屏显示[ALT+F4关闭][共1步][新弹出窗口并以全屏幕方式显示] ====1.将以下代码加入HTML的<body></body>之间: <form ...

  9. JavaScript特效源码(3、菜单特效)

    1.左键点击显示菜单 左键弹出式菜单[推荐][修改显示的文字及链接即可][共2步] ====1.将以下代码加入HEML的<head></head>之间: <style t ...

随机推荐

  1. Feign连接超时 Read timed out

    在远程调用的过程中由于连接超时,导致无法成功请求数据,下面是报错 项目中用的是spring-cloud-starter-openfeign 2.2.0版本 找到对应的文档,开始查阅资料 文档首页就找到 ...

  2. NX二次开发-UFUN读取本地文本文档uc4514a

    1 NX9+VS2012 2 3 #include <uf.h> 4 #include <uf_cfi.h> 5 #include <uf_ui.h> 6 7 us ...

  3. NX二次开发-UFUN单选菜单对话框uc1603

    NX11+VS2013 #include <uf.h> #include <uf_ui.h> UF_initialize(); //单选菜单对话框 char sPromptSt ...

  4. 数学相关比较 牛顿迭代法求开方 很多个n的平方分之一

    牛顿迭代法求开方 牛顿迭代法 作用: 求f(x) = 0 的解 方法:假设任意一点 x0, 求切线与x轴交点坐标x1, 再求切线与x轴交点坐标x2,一直重复,直到f(xn) 与0的差距在一个极小的范围 ...

  5. ionic-CSS:ionic 网格(Grid)

    ylbtech-ionic-CSS:ionic 网格(Grid) 1.返回顶部 1. ionic 网格(Grid) ionic 的网格(Grid)和其他大部分框架有所不同,它采用了弹性盒子模型(Fle ...

  6. ubuntu 12.04系统黑屏,登录界面黑屏

    ubuntu 12.04系统黑屏,登录界面黑屏 原文链接:http://www.2cto.com/os/201305/213737.html   1.硬件环境     Intel® Core™ i5- ...

  7. 20140308 std::fill

    std::fill  在[first, last)范围内填充值:std::fill(v.begin(), v.end(), 100);http://blog.csdn.net/ilysony/arti ...

  8. vue点击跳转拨号界面

    <a :href="'tel:' + VipInfo.HotelPhone" style="text-decoration:none;color:black;opa ...

  9. sql 循环执行游标

    ---定义开始和结束时间 declare @st_dt datetime declare @en_dt datetime ---时间赋值 ' ' ---定义中间变量 declare @dt datet ...

  10. 配置Spring Security 错误:Property or field 'ROLE_USER' cannot be found

    在学习http://www.mkyong.com/spring-security/spring-security-hello-world-example/时,出现以下错误: Property or f ...