Single Paradox
10-13-2005, 05:50 AM
I have this code:
<script>
function createVar() {
for(i=1;i<document.links.length+1;i++){
var joe=new Array();
joe[i]=0;
}
}
</script>
<body onload="createVar();">
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a><br>
that is supposed to make a variable each time it sees a link, I have no idea if it is working or not but whenever I call to a function with the variable "joe" (ex. joe[1]), it says joe is undefined. I am making this for a fading script I made so that none of the fades clash together, this is my fading script:
<script>
var i=0;
var j=0;
var k=0;
var Timer;
function fade(id) {
if(k<=164){
clearTimeout(Timer);
window.status=i+" "+j+" "+k;
document.getElementById(id).style.backgroundColor='rgb('+ i +','+ j +','+ k +')';
i=i+3;
j=j+5;
k=k+5;
Timer=setTimeout(function() {fade(id)},0);
}else{
clearTimeout(Timer);
}
}
function fadeout(id) {
if(k>=0){
clearTimeout(Timer);
window.status=i+" "+j+" "+k;
document.getElementById(id).style.backgroundColor='rgb('+ i +','+ j +','+ k +')';
i=i-3;
j=j-5;
k=k-5;
Timer=setTimeout(function() {fadeout(id)},0);
}else{
clearTimeout(Timer);
}
}
</script>
<style>
a{font-variant:small-caps;
color:#FFFFFF;
text-decoration:none;
padding-left:25px;
font-weight:bold;
width:250px;
border:1px solid white;
background:url('http://www.singleparadox.com/images/DD_li_over.gif') no-repeat left;
}
</style>
<body bgcolor="black">
<a id="yus" onmouseover="fade(this.id);" onmouseout="fadeout(this.id);" href="http://www.singleparadox.com">Home</a><br>
<a id="yus2" onmouseover="fade(this.id);" onmouseout="fadeout(this.id);" href="http://www.singleparadox.com">Links</a><br>
<a id="yus3" onmouseover="fade(this.id);" onmouseout="fadeout(this.id);" href="http://www.singleparadox.com">Music</a><br>
<a id="yus4" onmouseover="fade(this.id);" onmouseout="fadeout(this.id);" href="http://www.singleparadox.com">Contact</a><br>
My goal is to dynamically create the variables I, J, K, and Timer each time it spots a link, so there will be like:
var I[0];
var I[1];
var I[2];
var J[0];
var J[1];
var J[2];
var K[0];
var K[1];
var K[2];
var Timer[0];
var Timer[1];
var Timer[2];
and so on and so forth, each time a link is spotted on a page. This method is so all the links don't depend on the single I,J,K, and Timer. Does anyone catch my drift? Is this even possible?
<script>
function createVar() {
for(i=1;i<document.links.length+1;i++){
var joe=new Array();
joe[i]=0;
}
}
</script>
<body onload="createVar();">
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a>
<a href=""> </a><br>
that is supposed to make a variable each time it sees a link, I have no idea if it is working or not but whenever I call to a function with the variable "joe" (ex. joe[1]), it says joe is undefined. I am making this for a fading script I made so that none of the fades clash together, this is my fading script:
<script>
var i=0;
var j=0;
var k=0;
var Timer;
function fade(id) {
if(k<=164){
clearTimeout(Timer);
window.status=i+" "+j+" "+k;
document.getElementById(id).style.backgroundColor='rgb('+ i +','+ j +','+ k +')';
i=i+3;
j=j+5;
k=k+5;
Timer=setTimeout(function() {fade(id)},0);
}else{
clearTimeout(Timer);
}
}
function fadeout(id) {
if(k>=0){
clearTimeout(Timer);
window.status=i+" "+j+" "+k;
document.getElementById(id).style.backgroundColor='rgb('+ i +','+ j +','+ k +')';
i=i-3;
j=j-5;
k=k-5;
Timer=setTimeout(function() {fadeout(id)},0);
}else{
clearTimeout(Timer);
}
}
</script>
<style>
a{font-variant:small-caps;
color:#FFFFFF;
text-decoration:none;
padding-left:25px;
font-weight:bold;
width:250px;
border:1px solid white;
background:url('http://www.singleparadox.com/images/DD_li_over.gif') no-repeat left;
}
</style>
<body bgcolor="black">
<a id="yus" onmouseover="fade(this.id);" onmouseout="fadeout(this.id);" href="http://www.singleparadox.com">Home</a><br>
<a id="yus2" onmouseover="fade(this.id);" onmouseout="fadeout(this.id);" href="http://www.singleparadox.com">Links</a><br>
<a id="yus3" onmouseover="fade(this.id);" onmouseout="fadeout(this.id);" href="http://www.singleparadox.com">Music</a><br>
<a id="yus4" onmouseover="fade(this.id);" onmouseout="fadeout(this.id);" href="http://www.singleparadox.com">Contact</a><br>
My goal is to dynamically create the variables I, J, K, and Timer each time it spots a link, so there will be like:
var I[0];
var I[1];
var I[2];
var J[0];
var J[1];
var J[2];
var K[0];
var K[1];
var K[2];
var Timer[0];
var Timer[1];
var Timer[2];
and so on and so forth, each time a link is spotted on a page. This method is so all the links don't depend on the single I,J,K, and Timer. Does anyone catch my drift? Is this even possible?