Javascript Scroller - Included Text File

Lukster's picture

They have: 64 posts

Joined: Sep 2001

Heyas guys, basically I have a client that wants a scrolling text bar, and want to be able to update it themselves. My Javascript skills are basically cut-'n'-paste so i was wondering if you can create an external .js file that they could change the text in and upload it and my script would pull it in each time...

Below is the current script code.

<script language="JavaScript1.2">

//Specify the marquee's width (in pixels)
var marqueewidth=550
//Specify the marquee's height
var marqueeheight=18
//Specify the marquee's marquee speed (larger is faster 1-10)
var marqueespeed=2
//configure background color:
var marqueebgcolor="#ffffff"
//Pause marquee onMousever (0=no. 1=yes)?
var pauseit=1

//Specify the marquee's content (don't delete tag)
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):

var marqueecontent='Just launched! WW2 Nominal Roll ---- Check out our new Professional Products section now! click here. Enjoy your stay!'

////NO NEED TO EDIT BELOW THIS LINE////////////
marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS
var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var iedom=document.all||document.getElementById
if (iedom)
document.write(''+marqueecontent+'')
var actualwidth=''
var cross_marquee, ns_marquee

function populate(){
if (iedom){
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
cross_marquee.style.left=marqueewidth+8
cross_marquee.innerHTML=marqueecontent
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
}
else if (document.layers){
ns_marquee=document.ns_marquee.document.ns_marquee2
ns_marquee.left=marqueewidth+8
ns_marquee.document.write(marqueecontent)
ns_marquee.document.close()
actualwidth=ns_marquee.document.width
}
lefttime=setInterval("scrollmarquee()",20)
}
window.onload=populate

function scrollmarquee(){
if (iedom){
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
else
cross_marquee.style.left=marqueewidth+8

}
else if (document.layers){
if (ns_marquee.left>(actualwidth*(-1)+8))
ns_marquee.left-=copyspeed
else
ns_marquee.left=marqueewidth+8
}
}

if (iedom||document.layers){
with (document){
document.write('')
if (iedom){
write('')
write('')
write('')
write('')
}
else if (document.layers){
write('')
write('')
write('')
}
document.write('')
}
}
</script>

"Whenever you do a thing, act as if all the world were watching."

Online Data Backup? I'd like to see that!

jammin's picture

They have: 222 posts

Joined: Sep 2002

so you would want the text for the marquee to be in a seperate file, why not just use the whole marquee in an external file?
i guess i really dont see why you would need to put the text into an external file...

but i guess you would just put

Quote: var marqueecontent='Just launched! WW2 Nominal Roll ---- Check out our new Professional Products section now! click here. Enjoy your stay!'

into an external js then have it load at the top. im fairly sure that should work.

since im really bored right now and have nothing better to do i guess i could work up the seperate scripts for you and check if they work...

anyone can do any amount of work provided it isnt the work they are supposed to be doing.

jammin's picture

They have: 222 posts

Joined: Sep 2002

ok... done... that didnt take long.

here is the script for the .js file called marquee

Quote:
var marqueewidth=550
var marqueeheight=18
var marqueespeed=2
var marqueebgcolor="#ffffff"
var pauseit=1

marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS
var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var iedom=document.all||document.getElementById
if (iedom)
document.write(''+marqueecontent+'')
var actualwidth=''
var cross_marquee, ns_marquee

function populate(){
if (iedom){
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
cross_marquee.style.left=marqueewidth+8
cross_marquee.innerHTML=marqueecontent
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
}
else if (document.layers){
ns_marquee=document.ns_marquee.document.ns_marquee2
ns_marquee.left=marqueewidth+8
ns_marquee.document.write(marqueecontent)
ns_marquee.document.close()
actualwidth=ns_marquee.document.width
}
lefttime=setInterval("scrollmarquee()",20)
}
window.onload=populate

function scrollmarquee(){
if (iedom){
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
else
cross_marquee.style.left=marqueewidth+8

}
else if (document.layers){
if (ns_marquee.left>(actualwidth*(-1)+8))
ns_marquee.left-=copyspeed
else
ns_marquee.left=marqueewidth+8
}
}

if (iedom||document.layers){
with (document){
document.write('')
if (iedom){
write('')
write('')
write('')
write('')
}
else if (document.layers){
write('')
write('')
write('')
}
document.write('')
}
}

here is the text that will scroll put it in a file called text.js

Quote:
var marqueecontent='Just launched! WW2 Nominal Roll ---- Check out our new Professional Products section now! click here. Enjoy your stay!'

and then just put

Quote:
<script src="text.js"></script>
<script src="marquee.js"></script>

into the head of the html document.

anyone can do any amount of work provided it isnt the work they are supposed to be doing.

Lukster's picture

They have: 64 posts

Joined: Sep 2001

Thanks Jammin, your a god Smiling

jammin's picture

They have: 222 posts

Joined: Sep 2002

well thats the first time i've been called that...

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.