Solved

How do I create a scrolling banner using text from an external txt file?

Posted on 2001-06-02
4
200 Views
Last Modified: 2008-03-06
I am trying to create a scrolling banner containing recient news on my website. because i will need to up date it regularly i want to be able to send a txt file to my webspace which the banner on the page will take text from.
0
Comment
Question by:andichilds
  • 4
4 Comments
 
LVL 5

Expert Comment

by:djbusychild
ID: 6149051
there are many scrolling text scripts around the net:

http://www.j-scripts.com/scripts/script045.asp
http://www.widomaker.com/~reboughner/W3C/scrollbanner/scroll.html

to be able to use a text file that's on the server you would need to use serverside script. If you cannot afford to use a serverside script to populate the content, then you can get by by using either an applet:

http://javaboutique.internet.com/ZeBanner/

or an html file instead of a plain ol' text file for your banner content.

0
 
LVL 5

Expert Comment

by:djbusychild
ID: 6149057
tell me if you need an example of how to do that. If you don't want to complicate manners, than applet is the easy way to go.
0
 
LVL 5

Expert Comment

by:djbusychild
ID: 6149087
the scrolling part is very simple, the loading news from external file cross-browser is the chunk of the code..

your banner file will look like this:

<form method="get" action="#">
<textarea name="bannersrc">
news1
news2
news3
news4
</textarea>
</form>

------------------------------
the page you will have will be like this
------------------------------

<html>
<head>

<script>
doc=document;
IE=(doc.all)?1:0;
delim=/\r*\n/g; /* this is the delimiter for your news */
spacer=" --- "; /* this is how it'll be delimited on screen */
box=null;
speed=300;
full_banner_text="";

function scrollBanner(){
 theText=box.value;
 box.value=theText.substring(1)+theText.substring(0,1);
}

function setBanner(box,str){
 var news_list=str.replace(delim,spacer);
 box.value=news_list;

}

function loadBannerText(){
 var src=(IE)?doc.frames["bannerSrc"]:doc.layers["bannerSrc"];
 return src.document.forms[0]["bannersrc"].value;
}

window.onload=function() {
 box=doc.forms["bannerForm"]["bannerBox"]
 full_banner_text=loadBannerText();
 setBanner(box,full_banner_text);
 window.setInterval("scrollBanner()",100);
}

</script>

</head>
<body>

<iframe id="bannerSrc" frameborder="0" width="0" height="0" src="mybanner.htm"></iframe>
<layer visibility="hide" width="0" height="0" left="0" top="0" id="bannerSrc" src=mybanner.htm></layer>

<div align="center">

<form name="bannerForm" method="get" action="#">
<input name="bannerBox" type="text" size="40" style="width:300px;"><br />
</form>

</div>


</body>
</html>
0
 
LVL 5

Accepted Solution

by:
djbusychild earned 300 total points
ID: 6149090
I stole one of the scrolling code from one of the URL. =)
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question