facebook twitter youtube
in JavaScripts - 29 Mar, 2011, This Tutorial Has Been Viewed 15,702 Times.
by admin - no comments
Dynamically Changing hyperlink color on a website using javascript
VN:F [1.9.22_1171]
Rating: 5.7/10 (7 votes cast)

This tutorial will show you how to Dynamically Change hyperlink colors on a website using javascript. This script will create links with different colors [dancing links] once the page is loaded.


<!-- ONE STEP TO INSTALL DANCING LINKS:

   1.  Add the first code in the HEAD of your HTML document  -->

<!-- STEP ONE: Add the first code to the HEAD of your HTML document  -->

<head>
<body onload="changeColor()">
<script LANGUAGE="JavaScript">

function initArray() {
for (var i = 0; i < initArray.arguments.length; i++) {
this[i] = initArray.arguments[i];
}
this.length = initArray.arguments.length;
}
var colors = new initArray(
"red",
"blue",
"green",
"purple",
"black",
"tan",
"orange");
delay = .7; 
link = 1;
vlink = 3;
function changeColor() {
link = (link+1)%colors.length;
vlink = (vlink+1)%colors.length;
document.linkColor = colors[link];
document.vlinkColor = colors[vlink];
setTimeout("changeColor()",delay*1000);
}
// End -->
</script>

<h1><a href="http://mistonline.in">This is a test link</a></h1>

VN:F [1.9.22_1171]
Rating: 5.7/10 (7 votes cast)
Dynamically Changing hyperlink color on a website using javascript, 5.7 out of 10 based on 7 ratings

Incoming search terms:




coded by nessus

Leave a Reply

Close
Please support the site
By clicking any of these buttons you help our site to get better