Solved

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

Posted on 2001-06-02
4
195 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I stole one of the scrolling code from one of the URL. =)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now