I am needing, and would appreciate expert assistance for a Javascript program that I am using in a Website. The script is a Text and Image Fader, which only works on IE, but what I am trying to do is get it to work across the NS, FF and OPR browsers. What I have done is added global variables at the beginning of the existing script, however, I am not sure where to go from there. Even though the script is not showing any errors, and is still working in IE with the added code, I know there still needs to be a reference within the script to call the variables, but I am not sure how to add them.
I am providing the full code below for the script. This is not time sensitive, however, I am hoping that I can receive a response back in 3 days.
[code=html]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR " content="Micros oft FrontPage 4.0">
<meta name="ProgId" content="FrontP age.Editor.Docu ment">
<title>Wear Gear Text Fader</title>
<SCRIPT LANGUAGE="JavaS cript">
[/code][code=javascript]
<!-- Begin
var isDOM = (document.getEl ementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layer s ? true : false);
function getRef(id) {
if (isDOM) return document.getEle mentById(id);
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}
function getSty(id) {
return (isNS4 ? getRef(id) : getRef(id).styl e);
}
// add as many or as few messages as you would like
var msg=new Array()
msg[0]="<CENTER>Yo u can see more scripts like this one...</CENTER>";
msg[1]="<CENTER>...wh en you visit the JavaScript Source.</CENTER>";
msg[2]="<CENTER>Ju st type in \"<A href='http://javascript.inte rnet.com/'>javascript.in ternet.com</A>\"</CENTER>";
msg[3]="<CENTER>Yo ur computer can handle the rest.</CENTER>";
// set your first set of colors. Use as many or as few as you wish.
var colors1=new Array("ffffff", "eeeeff", "ddddff", "ccccff", "bbbbff", "aaaaff", "9999ff",
"8888ff", "7777ff", "6666ff", "5555ff", "4444ff", "3333ff","2222f f", "1111ff", "0000ff")
//set your second set of colors
// *** must have exactly the same number of colors as the array above ***
var colors2=new Array("ffffff", "ffeeee", "ffdddd", "ffcccc", "ffbbbb", "ffaaaa", "ff9999",
"ff8888", "ff7777", "ff6666", "ff5555", "ff4444", "ff3333", "ff2222", "ff1111", "ff0000")
//set the height of the display in pixels
high=60;
//set the width of the display in pixels
wide=350;
//set the pixel coordinates for the upper left hand corner of the display
Xpos=220;
Ypos=180;
// move the display away from the edges of the background
pad=15;
// set the background color of the display
bgcol="ffffff";
//add a background image if you want.
// *** for no image, just leave empty quotes (ex. cellbg=""; ) ***
cellbg="faderbg .jpg";
// set the font
fntFam="verdana ,helvetica,aria l";
fntSize=14;
// set how how many seconds you want the message to stay remain at totality.
pause=2.5;
// Do not edit these values below!!!
icolor=0;
mcolor=1;
imsg=0;
spWidth=wide-(2*pad);
totality=false;
glowing=true;
var theMsg="";
var cellcontent="";
pause=pause*100 0;
if(cellbg.lengt h>4){cellbg=" background="+ce llbg}
else{cellbg=""; }
function doPause(){
totality=false; t=setTimeout("c hangecolor()",p ause);
}
function initiate(){
getContentColor ();
getMsg();
getCellContent( );
if(document.all ){
msgbg.innerHTML =cellcontent;
msgfade.innerHT ML=theMsg;
msgbg.style.pos Left=Xpos;
msgbg.style.pos Top=Ypos;
msgfade.style.p osLeft=Xpos+pad ;
msgfade.style.p osTop=Ypos+pad;
t=setTimeout("c hangecolor()",5 0);}
if(document.lay ers ? true : false){
document.msgbg. document.write( cellcontent);
document.msgbg. document.close( );
document.msgfad e.document.writ e(theMsg);
document.msgfad e.document.clos e();
document.msgbg. left=Xpos;
document.msgbg. top=Ypos;
document.msgfad e.left=Xpos+pad ;
document.msgfad e.top=Ypos+pad;
t=setTimeout("c hangecolor()",1 00);}
}
function changecolor(){
if(totality==tr ue){doPause();}
else{
getMsg();
getContentColor ();
if(document.all ){
msgfade.innerHT ML=theMsg;
t=setTimeout("c hangecolor()",5 0);}
if(document.lay ers){
document.msgfad e.document.writ e(theMsg);
document.msgfad e.document.clos e();
t=setTimeout("c hangecolor()",7 0);}
}
}
function getFadeColor(){
icolor=icolor-1;
if(mcolor==1){c ontentcolor=col ors1[icolor];}
else{contentcol or=colors2[icolor];}
}
function getGlowColor(){
icolor=icolor+1 ;
if(mcolor==1){c ontentcolor=col ors1[icolor];}
else{contentcol or=colors2[icolor];}
}
function changemsg(){
if(imsg==msg.le ngth-1){imsg=0; mcolor=1;}
else if(imsg != msg.lenght-1 && mcolor==1){imsg =imsg+1; mcolor=0;}
else{imsg=imsg+ 1; mcolor=1;}
}
function getContentColor (){
if(icolor==colo rs1.length-1 && glowing==true){
getFadeColor(); glowing=false; totality=true;}
else if(icolor < colors1.length && glowing==true){
getGlowColor(); }
else if(icolor < 1 && glowing==false) {changemsg(); getGlowColor(); glowing=true;}
else{getFadeCol or();}
}
function getMsg() {
theMsg="<span style='font-size:"+fntSize+ "pt; font-family:"+fntFam +"; width:"+spWidth +";'>"
theMsg+="<B><fo nt color="+content color+">"+msg[imsg]+"</font></B> "
theMsg+="</span>"
}
function getCellContent( ){
cellcontent="<T ABLE height="+high+
" width="+wide+" bgcolor="+bgcol +" cellpadding=0 cellspacing=0>< TR><TD"+cellbg+ "> </TD></TR></TABLE>"}
// End -->[/code][code=html]
</script>
</head>
<BODY onLoad="initiat e()">
<DIV id=msgbg style="position : absolute;"></DIV>
<DIV id=msgfade style="position : absolute;"></DIV>
</body>
</html>[/code]
Thank you in advance for your efforts, and I look forward to your expertise in this matter and will credit your contribution within the script.
Sincere regards,
Michael M.
I am providing the full code below for the script. This is not time sensitive, however, I am hoping that I can receive a response back in 3 days.
[code=html]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR " content="Micros oft FrontPage 4.0">
<meta name="ProgId" content="FrontP age.Editor.Docu ment">
<title>Wear Gear Text Fader</title>
<SCRIPT LANGUAGE="JavaS cript">
[/code][code=javascript]
<!-- Begin
var isDOM = (document.getEl ementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layer s ? true : false);
function getRef(id) {
if (isDOM) return document.getEle mentById(id);
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}
function getSty(id) {
return (isNS4 ? getRef(id) : getRef(id).styl e);
}
// add as many or as few messages as you would like
var msg=new Array()
msg[0]="<CENTER>Yo u can see more scripts like this one...</CENTER>";
msg[1]="<CENTER>...wh en you visit the JavaScript Source.</CENTER>";
msg[2]="<CENTER>Ju st type in \"<A href='http://javascript.inte rnet.com/'>javascript.in ternet.com</A>\"</CENTER>";
msg[3]="<CENTER>Yo ur computer can handle the rest.</CENTER>";
// set your first set of colors. Use as many or as few as you wish.
var colors1=new Array("ffffff", "eeeeff", "ddddff", "ccccff", "bbbbff", "aaaaff", "9999ff",
"8888ff", "7777ff", "6666ff", "5555ff", "4444ff", "3333ff","2222f f", "1111ff", "0000ff")
//set your second set of colors
// *** must have exactly the same number of colors as the array above ***
var colors2=new Array("ffffff", "ffeeee", "ffdddd", "ffcccc", "ffbbbb", "ffaaaa", "ff9999",
"ff8888", "ff7777", "ff6666", "ff5555", "ff4444", "ff3333", "ff2222", "ff1111", "ff0000")
//set the height of the display in pixels
high=60;
//set the width of the display in pixels
wide=350;
//set the pixel coordinates for the upper left hand corner of the display
Xpos=220;
Ypos=180;
// move the display away from the edges of the background
pad=15;
// set the background color of the display
bgcol="ffffff";
//add a background image if you want.
// *** for no image, just leave empty quotes (ex. cellbg=""; ) ***
cellbg="faderbg .jpg";
// set the font
fntFam="verdana ,helvetica,aria l";
fntSize=14;
// set how how many seconds you want the message to stay remain at totality.
pause=2.5;
// Do not edit these values below!!!
icolor=0;
mcolor=1;
imsg=0;
spWidth=wide-(2*pad);
totality=false;
glowing=true;
var theMsg="";
var cellcontent="";
pause=pause*100 0;
if(cellbg.lengt h>4){cellbg=" background="+ce llbg}
else{cellbg=""; }
function doPause(){
totality=false; t=setTimeout("c hangecolor()",p ause);
}
function initiate(){
getContentColor ();
getMsg();
getCellContent( );
if(document.all ){
msgbg.innerHTML =cellcontent;
msgfade.innerHT ML=theMsg;
msgbg.style.pos Left=Xpos;
msgbg.style.pos Top=Ypos;
msgfade.style.p osLeft=Xpos+pad ;
msgfade.style.p osTop=Ypos+pad;
t=setTimeout("c hangecolor()",5 0);}
if(document.lay ers ? true : false){
document.msgbg. document.write( cellcontent);
document.msgbg. document.close( );
document.msgfad e.document.writ e(theMsg);
document.msgfad e.document.clos e();
document.msgbg. left=Xpos;
document.msgbg. top=Ypos;
document.msgfad e.left=Xpos+pad ;
document.msgfad e.top=Ypos+pad;
t=setTimeout("c hangecolor()",1 00);}
}
function changecolor(){
if(totality==tr ue){doPause();}
else{
getMsg();
getContentColor ();
if(document.all ){
msgfade.innerHT ML=theMsg;
t=setTimeout("c hangecolor()",5 0);}
if(document.lay ers){
document.msgfad e.document.writ e(theMsg);
document.msgfad e.document.clos e();
t=setTimeout("c hangecolor()",7 0);}
}
}
function getFadeColor(){
icolor=icolor-1;
if(mcolor==1){c ontentcolor=col ors1[icolor];}
else{contentcol or=colors2[icolor];}
}
function getGlowColor(){
icolor=icolor+1 ;
if(mcolor==1){c ontentcolor=col ors1[icolor];}
else{contentcol or=colors2[icolor];}
}
function changemsg(){
if(imsg==msg.le ngth-1){imsg=0; mcolor=1;}
else if(imsg != msg.lenght-1 && mcolor==1){imsg =imsg+1; mcolor=0;}
else{imsg=imsg+ 1; mcolor=1;}
}
function getContentColor (){
if(icolor==colo rs1.length-1 && glowing==true){
getFadeColor(); glowing=false; totality=true;}
else if(icolor < colors1.length && glowing==true){
getGlowColor(); }
else if(icolor < 1 && glowing==false) {changemsg(); getGlowColor(); glowing=true;}
else{getFadeCol or();}
}
function getMsg() {
theMsg="<span style='font-size:"+fntSize+ "pt; font-family:"+fntFam +"; width:"+spWidth +";'>"
theMsg+="<B><fo nt color="+content color+">"+msg[imsg]+"</font></B> "
theMsg+="</span>"
}
function getCellContent( ){
cellcontent="<T ABLE height="+high+
" width="+wide+" bgcolor="+bgcol +" cellpadding=0 cellspacing=0>< TR><TD"+cellbg+ "> </TD></TR></TABLE>"}
// End -->[/code][code=html]
</script>
</head>
<BODY onLoad="initiat e()">
<DIV id=msgbg style="position : absolute;"></DIV>
<DIV id=msgfade style="position : absolute;"></DIV>
</body>
</html>[/code]
Thank you in advance for your efforts, and I look forward to your expertise in this matter and will credit your contribution within the script.
Sincere regards,
Michael M.
Comment