473,395 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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;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=thems g
document.getElementById("alertit").style.width=win dowwidth
document.getElementById("alertit").scrollAmount=sp eed
document.getElementById("alertit").scrollDelay=20
document.getElementById("alertit").loop=loops
document.getElementById("alertit").onfinish=functi on(){
document.getElementById("alertit").style.visibilit y="hidden"
}
}

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

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

</script>

----------------------------------------------------------------------------
--------------------------
Jul 23 '05 #1
1 1484
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

Adam wrote:
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???


Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Julie Siebel | last post by:
Apologies...I'm sure this has been asked before, but I can't seem to come up with the correct Google search terms. While my problem is with stylesheets, the errors are being caused by my...
2
by: David | last post by:
How do you turn an iframe scrollbar off, from within javascript, after the iframe has been loaded? In my example, the page with the iframe on it is initially set to scrolling=yes, however, I want...
2
by: Adam | last post by:
I have a scrollbar that runs at the top of my page, I have it in a external js file and call it in the head tags of the webpage code. can you one tell me how to get this code to work with other...
19
by: Eva | last post by:
Hi, I'm really really really new to javascripts and so i couldn't really comprehend thoroughly on the the previous posts regarding this issue. Anyways, I'm setting up a picture album site....
1
by: Mosher | last post by:
Hi all, is there a good way to have a popup window appear using Javascript and the html "map" tag? Here is my code: <map name="navigation"> <area shape="rect" coords="5,57,45,70"...
2
by: Per Jessen | last post by:
This is a javascript question, possibly somewhat inappropriate for this group, but here we go: (please redirect me to the right place to ask). In Microsoft Internet Explorer (5 and up) using...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: johnperkins | last post by:
I am curious as to why the scrollbar.scroll event gets called twice Here is an example of my code Private Sub vsbMoveCar_Scroll(ByVal sender As System.Object, ByVal e As...
2
by: qhimq | last post by:
Hi windows API programmers, I'm so close to making my vertical scrollbar to work properly, except for: After pushing or dragging the scrollbar the window scrolls properly until I let go of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.