Javascript Scrollbar called from a js file

A

Adam

Hi

I have a script for a scrollbar that appears at the top of my webpage, I
want to be able to call the script from a central file so I can add the
scrollbar to all my pages and I will only have to edit the main file which
will change the text on all my pages Can anyone help???

this is script for the scrollbar

---------------------------------------------------------------------------
<marquee id="alertit"
style="position:absolute;left:0px;top:0;background-color:"
onMouseover="this.scrollAmount=1"
onMouseout="this.scrollAmount=speed"></marquee>
<script type="text/javascript">



var themsg='<span style="font: 22px
Arial;color:#FFCC66;"><b>Messages::::::::::: </b></span>'
var speed=4 //speed of scroller (1-10 or more)
var loops=4 //specify number of times message scrolls across screen (an
integer or "infinite")

function populatescroller(){
var windowwidth=iecompattest().clientWidth
document.getElementById("alertit").innerHTML=themsg
document.getElementById("alertit").style.width=windowwidth
document.getElementById("alertit").scrollAmount=speed
document.getElementById("alertit").scrollDelay=20
document.getElementById("alertit").loop=loops
document.getElementById("alertit").onfinish=function(){
document.getElementById("alertit").style.visibility="hidden"
}
}

function iecompattest(){
return (document.compatMode!="BackCompat")? document.documentElement :
document.body
}

if (document.all && document.getElementById){
window.onload=populatescroller
window.onresize=populatescroller
}

</script>
 
V

Vincent van Beveren

yes. Just put the code in a .js file and include it in the header

to convert the HTML into a js document (for example: myscrollthing.js)
do the following:

- change the HTML code of the marquee into document.writeln

document.write('<marquee id="alertit"
style="position:absolute;left:0px;top:0;background-color:"
onMouseover="this.scrollAmount=1"
onMouseout="this.scrollAmount=speed"></marquee>');

- remove the script tags.

- Now in each document you'll need to do the following at the location
you want the marquee to appear:

<SCRIPT LANGUAGE="JavaScript" SRC="myscrollthing.js"></SCRIPT>

And that should do it

Vincent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,217
Latest member
IRMNikole

Latest Threads

Top