Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fade out to work in NS6

Status
Not open for further replies.

bch33

Technical User
Oct 13, 2001
151
US
Does anyone know what (if anything)I can add to the script below to make it work in NS6? It works fine in NS4 and EI5.
Thanks
bch



<HEAD>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! -->
<!-- Ken Tholke, kentholke@firstsaga.com. -->

<!-- Begin
var msg=new Array()
msg[0]=&quot;<CENTER> Type the text...</CENTER>&quot;;
msg[1]=&quot;<CENTER> for all to see</CENTER>&quot;;
msg[2]=&quot;<CENTER>Type again...</CENTER>&quot;;


// set your first set of colors. Use as many or as few as you wish.
var colors1=new Array(&quot;ffffff&quot;, &quot;eeeeff&quot;, &quot;ddddff&quot;, &quot;ccccff&quot;, &quot;bbbbff&quot;, &quot;aaaaff&quot;, &quot;9999ff&quot;,
&quot;8888ff&quot;, &quot;7777ff&quot;, &quot;666699&quot;, &quot;555599&quot;, &quot;444499&quot;, &quot;333399&quot;,&quot;222299&quot;, &quot;111199&quot;, &quot;000099&quot;)

//set your second set of colors
// *** must have exactly the same number of colors as the array above ***
var colors2=new Array(&quot;ffffff&quot;, &quot;eeeeff&quot;, &quot;ddddff&quot;, &quot;ccccff&quot;, &quot;bbbbff&quot;, &quot;aaaaff&quot;, &quot;9999ff&quot;,
&quot;8888ff&quot;, &quot;7777ff&quot;, &quot;6666ff&quot;, &quot;5555ff&quot;, &quot;4444ff&quot;, &quot;3333ff&quot;,&quot;2222ff&quot;, &quot;1111ff&quot;, &quot;000099&quot;)


//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=&quot;ffffff&quot;;

//add a background image if you want.
// *** for no image, just leave empty quotes (ex. cellbg=&quot;&quot;; ) ***
cellbg=&quot;faderbg.jpg&quot;;

// set the font
fntFam=&quot;verdana,helvetica,arial&quot;;
fntSize=14;

// set how how many seconds you want the message to stay remain at totality.
pause=5.5;


// Do not edit these values below!!!

icolor=0;
mcolor=1;
imsg=0;
spWidth=wide-(2*pad);
totality=false;
glowing=true;
var theMsg=&quot;&quot;;
var cellcontent=&quot;&quot;;
pause=pause*1000;
if(cellbg.length>4){cellbg=&quot; background=&quot;+cellbg}
else{cellbg=&quot;&quot;;}

function doPause(){
totality=false; t=setTimeout(&quot;changecolor()&quot;,pause);
}
function initiate(){
getContentColor();
getMsg();
getCellContent();
if(document.all){
msgbg.innerHTML=cellcontent;
msgfade.innerHTML=theMsg;
msgbg.style.posLeft=Xpos;
msgbg.style.posTop=Ypos;
msgfade.style.posLeft=Xpos+pad;
msgfade.style.posTop=Ypos+pad;
t=setTimeout(&quot;changecolor()&quot;,50);}
if(document.layers){
document.msgbg.document.write(cellcontent);
document.msgbg.document.close();
document.msgfade.document.write(theMsg);
document.msgfade.document.close();
document.msgbg.left=Xpos;
document.msgbg.top=Ypos;
document.msgfade.left=Xpos+pad;
document.msgfade.top=Ypos+pad;
t=setTimeout(&quot;changecolor()&quot;,100);}
}
function changecolor(){
if(totality==true){doPause();}
else{
getMsg();
getContentColor();
if(document.all){
msgfade.innerHTML=theMsg;
t=setTimeout(&quot;changecolor()&quot;,50);}
if(document.layers){
document.msgfade.document.write(theMsg);
document.msgfade.document.close();
t=setTimeout(&quot;changecolor()&quot;,70);}
}
}
function getFadeColor(){
icolor=icolor-1;
if(mcolor==1){contentcolor=colors1[icolor];}
else{contentcolor=colors2[icolor];}
}
function getGlowColor(){
icolor=icolor+1;
if(mcolor==1){contentcolor=colors1[icolor];}
else{contentcolor=colors2[icolor];}
}
function changemsg(){
if(imsg==msg.length-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==colors1.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{getFadeColor();}
}
function getMsg() {
theMsg=&quot;<span style='font-size:&quot;+fntSize+&quot;pt; font-family:&quot;+fntFam+&quot;; width:&quot;+spWidth+&quot;;'>&quot;
theMsg+=&quot;<B><font color=&quot;+contentcolor+&quot;>&quot;+msg[imsg]+&quot;</font></B> &quot;
theMsg+=&quot;</span>&quot;
}
function getCellContent(){
cellcontent=&quot;<TABLE height=&quot;+high+
&quot; width=&quot;+wide+&quot; bgcolor=&quot;+bgcol+&quot; cellpadding=0 cellspacing=0><TR><TD&quot;+cellbg+&quot;> </TD></TR></TABLE>&quot;}
// End -->
</script>

</HEAD>

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->

<BODY onLoad=&quot;initiate()&quot;>
<!-- STEP THREE: Copy this code into the BODY of your HTML document -->
<table width=&quot;75%&quot; border=&quot;1&quot; align=&quot;center&quot;>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<table width=&quot;75%&quot; border=&quot;1&quot; align=&quot;center&quot;>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
<table width=&quot;91%&quot; border=&quot;1&quot; height=&quot;91&quot; align=&quot;center&quot;>
<tr>
<td height=&quot;164&quot; width=&quot;100&quot;>&nbsp;</td>
<td height=&quot;164&quot; width=&quot;100&quot;>&nbsp;</td>
<td height=&quot;164&quot; width=&quot;100&quot;>&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p><DIV id=msgbg style=&quot;position: absolute;&quot;></DIV>
<DIV id=msgfade style=&quot;position: absolute;&quot;></DIV>

<!-- Script Size: 5.17 KB -->
<font color=&quot;#FFFFFF&quot;></font>
 
I think that your problem is that NN6 recognises document.all, not document.layers, but the IE part of the program uses posLeft and posTop - which NN doesn't accept (I think).


You could change the .posLeft=xPos
to .left=xPos+&quot;px&quot;

which is a more generic form

Ian

 
Ian,
It didn't quite do the trick - If you have any other ideas let me know...
Thanks for your reply
bch
 
Everywhere where you detect for document.layers and document.all, make sure you detect for Netscape 6 and you may have to rewrite some of the code to work in NEtscape 6.

For Example, in function initiate(), just by a quick glance it looks as if you can get away with using the same code in IE and Netscape, but you might have to modify it a bit.

for example,

function initiate(){
getContentColor();
getMsg();
getCellContent();
if((document.all) || (document.sidebar)){
msgbg = document.getElementById(&quot;msgbg&quot;);
msgfade = document.getElementById(&quot;msgbg&quot;);
msgbg.innerHTML=cellcontent;
msgfade.innerHTML=theMsg;
msgbg.style.posLeft=Xpos;
if (document.getElementById){
msgbg.style.left=Xpos + &quot;px&quot;;
msgbg.style.top = Ypos + &quot;px&quot;;
msgfade.style.left=Xpos+pad + &quot;px&quot;;
msgfade.style.top=Ypos+pad + &quot;px&quot;;
} else {
msgbg.style.posTop=Ypos;
msgfade.style.posLeft=Xpos+pad;
msgfade.style.posTop=Ypos+pad;
}
t=setTimeout(&quot;changecolor()&quot;,50);}
if(document.layers){
document.msgbg.document.write(cellcontent);
document.msgbg.document.close();
document.msgfade.document.write(theMsg);
document.msgfade.document.close();
document.msgbg.left=Xpos;
document.msgbg.top=Ypos;
document.msgfade.left=Xpos+pad;
document.msgfade.top=Ypos+pad;
t=setTimeout(&quot;changecolor()&quot;,100);}
}


You just have to make sure you use Netscape 6's DOM correctly. HOpe that helps.

You will have to change stuff in more than just that one function. ===
Supports Mozilla and Web Standards
Knows HTML/XHTML, CSS1, JavaScript, PHP, C++, DOM1
===
 
Thanks,
I'm quite the beginner with this stuff but I'll take each function and work with it and see what happens
appreciate the help
bch
 
Hi there bch

I am also a beginner in js and would like to know whether you got this script to work as I am looking for the same thing.

landyw
 
If you guys need help check out library.southern.edu
and look at the source code for the menus on any secondary page these work in all three browsers the same.

Remember
Document.all is IE
document.layers is NS4
and document.getElementById is NS6
Make sure you add if statements for all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top