• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

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

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
andichilds
Asked:
andichilds
  • 4
1 Solution
 
djbusychildCommented:
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
 
djbusychildCommented:
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
 
djbusychildCommented:
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
 
djbusychildCommented:
I stole one of the scrolling code from one of the URL. =)
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now