官方淘宝店 易迪拓培训 旧站入口
首页 > 仿真设计 > 射频仿真设计学习 > 网站链接标题闪亮代码

网站链接标题闪亮代码

05-08
其实很简单,就是运用javascript 代码实现的,方法:
1. 将下列代码另存为color.js (粘贴到记事本另存为color.js,保存类型为所有文件。)


  1. var rate = 100;
  2. var obj;
  3. var act = 0;
  4. var elmH = 0;
  5. var elmS = 239;
  6. var elmV = 255;
  7. var clrOrg;
  8. var TimerID;
  9. if (navigator.appName.indexOf("Microsoft",0) != -1 && parseInt(navigator.appVersion) >= 4) {
  10. Browser = true;
  11. } else {
  12. Browser = false;
  13. }
  14. if (Browser) {
  15. document.onmouseover = doRainbowAnchor;
  16. document.onmouseout = stopRainbowAnchor;
  17. }
  18. function doRainbow()
  19. {
  20. if (Browser && act != 1) {
  21. act = 1;
  22. obj = event.srcElement;
  23. clrOrg = obj.style.color;
  24. TimerID = setInterval("ChangeColor()",100);
  25. }
  26. }
  27. function stopRainbow()
  28. {
  29. if (Browser && act != 0) {
  30. obj.style.color = clrOrg;
  31. clearInterval(TimerID);
  32. act = 0;
  33. }
  34. }
  35. function doRainbowAnchor()
  36. {
  37. if (Browser && act != 1) {
  38. obj = event.srcElement;
  39. while (obj.tagName != 'A' && obj.tagName != 'BODY') {
  40. obj = obj.parentElement;
  41. if (obj.tagName == 'A' || obj.tagName == 'BODY')
  42. break;
  43. }
  44. if (obj.tagName == 'A' && obj.href != '') {
  45. act = 1;
  46. clrOrg = obj.style.color;
  47. TimerID = setInterval("ChangeColor()",100);
  48. }
  49. }
  50. }
  51. function stopRainbowAnchor()
  52. {
  53. if (Browser && act != 0) {
  54. if (obj.tagName == 'A') {
  55. obj.style.color = clrOrg;
  56. clearInterval(TimerID);
  57. act = 0;
  58. }
  59. }
  60. }
  61. function ChangeColor()
  62. {
  63. obj.style.color = makeColor();
  64. }
  65. function makeColor()
  66. {
  67. if (elmS == 0) {
  68. elmR = elmV; elmG = elmV; elmB = elmV;
  69. }
  70. else {
  71. t1 = elmV;
  72. t2 = (255 - elmS) * elmV / 255;
  73. t3 = elmH % 60;
  74. t3 = (t1 - t2) * t3 / 60;
  75. if (elmH < 60) {
  76. elmR = t1; elmB = t2; elmG = t2 + t3;
  77. }
  78. else if (elmH < 120) {
  79. elmG = t1; elmB = t2; elmR = t1 - t3;
  80. }
  81. else if (elmH < 180) {
  82. elmG = t1; elmR = t2; elmB = t2 + t3;
  83. }
  84. else if (elmH < 240) {
  85. elmB = t1; elmR = t2; elmG = t1 - t3;
  86. }
  87. else if (elmH < 300) {
  88. elmB = t1; elmG = t2; elmR = t2 + t3;
  89. }
  90. else if (elmH < 360) {
  91. elmR = t1; elmG = t2; elmB = t1 - t3;
  92. }
  93. else {
  94. elmR = 0; elmG = 0; elmB = 0;
  95. }
  96. }
  97. elmR = Math.floor(elmR);
  98. elmG = Math.floor(elmG);
  99. elmB = Math.floor(elmB);
  100. clrRGB = '#' + elmR.toString(16) + elmG.toString(16) + elmB.toString(16);
  101. elmH = elmH + rate;
  102. if (elmH >= 360)
  103. elmH = 0;
  104. return clrRGB;
  105. }

复制代码

2. 上传color.js文件到你网站的任意地方(但是你得找到访问它的绝对地址哦,我是在根目录下面新建一个js文件夹,放在js文件夹里面的。)
3. 进后台,在全局-站点信息-网站第三方统计代码: <SCRIPT src="/js/color.js"></SCRIPT> ,提交后更新缓存即可。


Top