Here's one that has bothered me for some time, the answer is probably simple yet, so far has eluded me. When I write code and want to pass the arguments from one function to another I often, if not always have to do something like this (example from some code I'm working on, it works but, looks sloppy):
Notice the comment. If I pass arg1 and arg2 directly to the moz_fade function, I get an error like img1 is not defined or has no properties. Using the above code, it works. There must be a better way.Code:<script type="text/JavaScript"><!-- i=100; function moz_switch(arg1,arg2){ x=arg1;// why are these two declarations necessary? y=arg2; fade=setInterval("moz_fade(x,y)",90); } function moz_fade(img1,img2){ document.getElementById(img1).style.MozOpacity=i/100; document.getElementById(img2).style.MozOpacity=Math.abs(i/100-1) i=(i-1); if (i==0){ clearInterval(fade); i=100; } } //--> </script>



Reply With Quote

Bookmarks