<script type="text/javascript" src="js/colorFader.js"></script>
My path (above) is correct, so I'm guessing its something to do with the "onload" command at the end of the code. The code works just fine if I paste it into the <head> tag of my web page adding the standard javascript open and close <script> tags, but as soon as I save it as an external file, it breaks. If anyone could help out as to how to fix this, I would sure appreciate it, as I need to put this on several hundred pages. Thanks
-------------------------------------
Expand|Select|Wrap|Line Numbers
- //Created by Fader Maker (http://www.bosiljak.hr/fadermaker/)
- var fmTimer = null;
- var fmfg = false;
- function fminit(){
- if (!document.getElementById) return;
- fma1=0xff; fma2=0x00; fma3=0xff;
- fma4=0xff; fma5=0x00; fma6=0x00;
- if (!fmfg){
- fmtemp=fma1; fma1=fma4; fma4=fmtemp; fmtemp=fma2; fma2=fma5; fma5=fmtemp; fmtemp=fma3; fma3=fma6; fma6=fmtemp;
- }
- fmfg = !fmfg;
- fmFade();
- }
- function fmToHex(n){
- var hexChars = "0123456789ABCDEF";
- if (n == 0) return "00";
- var j, n;
- var temp = "";
- while (n != 0){
- j = n % 16;
- n = (n - j)/16;
- temp = hexChars.charAt(j) + temp;
- }
- if (temp.length < 2){
- temp = "0" + temp;
- }
- return temp;
- }
- function fmFade(){
- obj = document.getElementById('tekst').style;
- fmcolor = "#" + fmToHex(fma1) + fmToHex(fma2) + fmToHex(fma3);
- obj.color = fmcolor;
- if (fma1 != fma4){
- if (fma4 > fma1){fma1++;}
- else{fma1--;}}
- if (fma2 != fma5){
- if (fma5 > fma2){fma2++;}
- else{fma2--;}}
- if (fma3 != fma6){
- if (fma6 > fma3){fma3++;}
- else{fma3--;}}
- if ((fma1 == fma4) && (fma2 == fma5) && (fma3 == fma6)){
- window.clearTimeout(fmTimer);
- fminit()}
- else{
- fmTimer = window.setTimeout("fmFade()",0);
- }
- }
- onload = fminit
The HTML part of the code in the body consists of adding an <span id="tekst" > tag around the text I want to effect. </span>
Also I tried taking off the "onload = fminit" in the external file, but no luck, and I get no error codes either way.