PDA

View Full Version : Conflicting Scripts amd Spacing Porblems



CDNCommando
04-10-2005, 01:21 AM
Script1:
Cross browser Marquee script
URL:
http://www.dynamicdrive.com/dynamicindex2/cmarquee.htm


Script2:
Fading scroller
URL:
http://www.dynamicdrive.com/dynamicindex2/fadescroll.htm

Hello everyone

I'm trying to add both of the above scripts to my site and they seem to be conflicting with each other and I was wondering if anybody knew what to change or if I can change anything to make the scripts run nicely on the same page. The other two problems Im having are with the first script, the cross browser marquee script. I was wondering if it was possible to change the border color to somthing other that white. (Im trying to get it to CC0000) The last problem im having is with the spacing on sript 1. It seems to me that its impossible to have different messages with spaces in between. Everything its supposed to say comes across all at the same time even if I put spaces in between and it doesnt look quite right.

Any help would be greatly appreciated
Thanks CDNCommando

jscheuer1
04-10-2005, 03:38 AM
In no particular order. To change the border color of the marquee change this line:
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')to:
document.write('<table style="border:2px solid #CC0000;" cellspacing="0" cellpadding="0"><td>')To put spaces in the marqueecontent variable, you can use:
&nbsp;for each extra space you want. If you want alot of space, that will get messy, so you can use this alternate method (changes from the original demo highlighted red):
var marqueecontent='<nobr><pre><font face="Arial" size="3">Thank you for visiting <a href="http://www.dynamicdrive.com">Dynamic Drive.</a> If you find this script useful, please consider linking to us by <a href="../link.htm">click here.</a> Enjoy your stay!</font></pre></nobr>'With these changes, regular spaces will be displayed as spaces.

Now as to your original question, script conflicts, that is so common we have this for it:
.

CDNCommando
04-10-2005, 04:26 AM
I see can the problem now I just cant get it working.

SCRIPT 1: window.onload=dothis
SCRIPT 2: window.onload=dothat
RESOLUTION: <body onload="dothis();dothat()">

Thats whats going on I think I just need to fix this somehow and is not working for me the entire first script just disappears. The help with the color and spacing looks great thanks for your help!

jscheuer1
04-11-2005, 02:44 AM
What browser are you using? I tested in FF1.0.2, IE6 and NS7.2 with both scripts on one page and they both work, probably owing to browser peculiarities. Try getting rid of:


window.onload=populateand:


else if (document.getElementById)
window.onload=changecontentand adding to your body tag

<body onload="populate();if ((document.getElementById)&&((!window.addEventListener)&&(!window.attachEvent)))changecontent();">

CDNCommando
04-11-2005, 09:10 PM
I couldnt find the line i was supped to delete I must be using a modified version or somthing. This is the exact script im using.

<center>
<script language="JavaScript1.2">

/*
Fading Scroller- By DynamicDrive.com
For full source code, and usage terms, visit http://www.dynamicdrive.com
This notice MUST stay intact for use
*/

var delay=3000 //set delay between message change (in miliseconds)
var fcontent=new Array()
begintag='<font face="Arial" size=2>' //set opening tag, such as font declarations
fcontent[0]="Welcome to the home of the Special Ops Clan"
fcontent[1]="The conversion to battlefield 2 is near completion!"
fcontent[2]="Just need to get the info and the top marquee working together"
fcontent[3]="What kind of music should I put on the site?"
fcontent[4]="Leave no man behind!!!"

closetag='</font>'

var fwidth='100px' //set scroller width
var fheight='120px' //set scroller height

var fadescheme=1 //set 0 to fade text color from (white to black), 1 for (black to white)
var fadelinks=1 //should links inside scroller content also fade like text? 0 for no, 1 for yes.

///No need to edit below this line/////////////////

var hex=(fadescheme==0)? 255 : 0
var startcolor=(fadescheme==0)? "rgb(255,255,255)" : "rgb(0,0,0)"
var endcolor=(fadescheme==0)? "rgb(0,0,0)" : "rgb(255,255,255)"

var ie4=document.all&&!document.getElementById
var ns4=document.layers
var DOM2=document.getElementById
var faderdelay=0
var index=0

if (DOM2)
faderdelay=2000

//function to change content
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color=startcolor
document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
linksobj=document.getElementById("fscroller").getElementsByTagName("A")
if (fadelinks)
linkcolorchange(linksobj)
colorfade()
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag
else if (ns4){
document.fscrollerns.document.fscrollerns_sub.document.write(begintag+fcontent[index]+closetag)
document.fscrollerns.document.fscrollerns_sub.document.close()
}

index++
setTimeout("changecontent()",delay+faderdelay)
}

// colorfade() partially by Marcio Galli for Netscape Communications. ////////////
// Modified by Dynamicdrive.com

frame=20;

function linkcolorchange(obj){
if (obj.length>0){
for (i=0;i<obj.length;i++)
obj[i].style.color="rgb("+hex+","+hex+","+hex+")"
}
}

function colorfade() {
// 20 frames fading process
if(frame>0) {
hex=(fadescheme==0)? hex-12 : hex+12 // increase or decrease color value depd on fadescheme
document.getElementById("fscroller").style.color="rgb("+hex+","+hex+","+hex+")"; // Set color value.
if (fadelinks)
linkcolorchange(linksobj)

frame--;
setTimeout("colorfade()",20);
}

else{
document.getElementById("fscroller").style.color=endcolor;
frame=20;
hex=(fadescheme==0)? 255 : 0
}
}

if (ie4||DOM2)
document.write('<div id="fscroller" style="border:0px solid black;width:'+fwidth+';height:'+fheight+';padding:2px"></div>')

window.onload=changecontent
</script>
</center>

jscheuer1
04-11-2005, 09:35 PM
With that script, the job is much easier, just get rid of:

window.onload=populatefrom the marquee script and:

window.onload=changecontentfrom the fading scroll script and put this in your body tag:
<body onload="changecontent();populate();">

CDNCommando
04-12-2005, 12:42 AM
Everything is perferct now thanks man you have been a huge help