473,604 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>

----------------------------------------------------------------------------
--------------------------
Jul 23 '05 #1
1 1497
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:
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
2174
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 javascript, so this seemed a more appropriate place to post. I'm using a media=print style sheet to do a version of a web page that I am building. Currently, I'm working on the IE version. I have an HTML page and 2 style sheets which all validate...
2
19711
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 to be able to set the scrollbar=no, through javascript.
2
2166
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 browsers mainly Netscape 7 and above. Currently it doesn't display. this is the scroll bar code Thanks ----------------------------------------------------------------------
19
4606
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. When i click on a thumbnail or a picture, a larger picture pops up in a javascript window. But it has a space on the top and on the left of my larger pic in the pop-up window. How do i get rid of that? Also, i want the window to fit my my pic so...
1
3035
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" href="index.php" alt="Home"> </map> I would like to have this link be a Javascript "onclick" type popup function with no scrollbar, etc.
2
6498
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 Javascript how do I detect whether an IFRAME is displayed with or without a vertical scrollbar? The initial height of an IFRAME is fixed, so depending on the content, the browser will render it with a scrollbar or not. In Netscape et al. this is...
136
9283
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
1
3370
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 System.Windows.Forms.ScrollEventArgs) Handles vsbMoveCar.Scrol 'Position the up and down movemen 'Used when the scroll box is move picCar.Top = vsbMoveCar.Valu X +=
2
2307
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 mouse. When I let go the window scrolls another unit to which I don't want to happen. I want to have the scrollbar place the window where it was set rather than 1 unit up or down. Another odd thing is the WM_VSCROLL message is called once when...
0
7997
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7929
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8419
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8409
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8065
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8280
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5882
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3907
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.