时间: 2021-07-31 作者:daque
有的站点超链接鼠标移上去时有彩色闪耀功效,本来很大略即是挪用了一段js代码罢了。底下即是实行功效所需代码:<script language="javascript">
var rate = 30;var object;var act = 0;var elmh = 0;var elms = 128;var elmv = 255;var clrorg;var timerid;
if (navigator.appname.indexof("microsoft",0) != -1 && parseint(navigator.appversion) >= 4) {browser = true;} else {browser = false;}
function dorainbow(){if (browser && act != 1) {act = 1;object = event.srcelement;clrorg = object.style.color;timerid = setinterval("changecolor()",100);}}function stoprainbow(){if (browser && act != 0) {object.style.color = clrorg;clearinterval(timerid);act = 0;}}function dorainbowanchor(){if (browser && act != 1) {object = event.srcelement;while (object.tagname != 'a' && object.tagname != 'body') {object = object.parentelement;if (object.tagname == 'a' || object.tagname == 'body')break;}if (object.tagname == 'a' && object.href != '') {act = 1;clrorg = object.style.color;timerid = setinterval("changecolor()",100);}}}function stoprainbowanchor(){if (browser && act != 0) {if (object.tagname == 'a') {object.style.color = clrorg;clearinterval(timerid);act = 0;}}}function changecolor(){object.style.color = makecolor();}function makecolor(){if (elms == 0) {elmr = elmv; elmg = elmv; elmb = elmv;}else {t1 = elmv;t2 = (255 - elms) * elmv / 255;t3 = elmh % 60;t3 = (t1 - t2) * t3 / 60;
if (elmh < 60) {elmr = t1; elmb = t2; elmg = t2 + t3;}else if (elmh < 120) {elmg = t1; elmb = t2; elmr = t1 - t3;}else if (elmh < 180) {elmg = t1; elmr = t2; elmb = t2 + t3;}else if (elmh < 240) {elmb = t1; elmr = t2; elmg = t1 - t3;}else if (elmh < 300) {elmb = t1; elmg = t2; elmr = t2 + t3;}else if (elmh < 360) {elmr = t1; elmg = t2; elmb = t1 - t3;}else {elmr = 0; elmg = 0; elmb = 0;}}elmr = math.floor(elmr);elmg = math.floor(elmg);elmb = math.floor(elmb);clrrgb = '#' + elmr.tostring(16) + elmg.tostring(16) + elmb.tostring(16);elmh = elmh + rate;if (elmh >= 360)elmh = 0;return clrrgb;}document.onmouseover = dorainbowanchor;document.onmouseout = stoprainbowanchor;</script>把上头的代码另存为一个js文献,而后在想实行此功效的页面挪用即可!