Javascript Scrollbar called from a js file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adam

    Javascript Scrollbar called from a js file

    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;backg round-color:"
    onMouseover="th is.scrollAmount =1"
    onMouseout="thi s.scrollAmount= speed"></marquee>
    <script type="text/javascript">



    var themsg='<span style="font: 22px
    Arial;color:#FF CC66;"><b>Messa ges::::::::::: </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 populatescrolle r(){
    var windowwidth=iec ompattest().cli entWidth
    document.getEle mentById("alert it").innerHTML= themsg
    document.getEle mentById("alert it").style.widt h=windowwidth
    document.getEle mentById("alert it").scrollAmou nt=speed
    document.getEle mentById("alert it").scrollDela y=20
    document.getEle mentById("alert it").loop=loo ps
    document.getEle mentById("alert it").onfinish=f unction(){
    document.getEle mentById("alert it").style.visi bility="hidden"
    }
    }

    function iecompattest(){
    return (document.compa tMode!="BackCom pat")? document.docume ntElement :
    document.body
    }

    if (document.all && document.getEle mentById){
    window.onload=p opulatescroller
    window.onresize =populatescroll er
    }

    </script>

    ----------------------------------------------------------------------------
    --------------------------


  • Vincent van Beveren

    #2
    Re: Javascript Scrollbar called from a js file

    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.j s)
    do the following:

    - change the HTML code of the marquee into document.writel n

    document.write( '<marquee id="alertit"
    style="position :absolute;left: 0px;top:0;backg round-color:"
    onMouseover="th is.scrollAmount =1"
    onMouseout="thi s.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="JavaS cript" SRC="myscrollth ing.js"></SCRIPT>

    And that should do it

    Vincent

    Adam wrote:
    [color=blue]
    > 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???
    >
    >[/color]

    Comment

    Working...