View Full Version : using an external text file to get information
Hello all
I am using News Scroller V2.0 (Single Message Belt Conveyer) which is a great news scroller. WIthin the Javascript that is inserted in the source code to the page is the following (it tells the scroller what to write):
***********
//text: change to your own
wwholemessage='<nobr class=tab>$28 US - This powerful BUNDLE: '+
'<a class=tabb href="#" onClick=\'window.top.location.href="http://members.rogers.com/bazil/"\'><u>Vertical SCROLLER with Recall V4.0 + Multiple Message Belt CONVEYER V4.0 + Multiple Message BLINKER V2.0</u></a></nobr>';
//-- end Parameters-->
//-- begin: Scroller's Algorithm -->
*************
I would like it so that I can put this scroller on to many pages and that the message, rather than being on each page, is pulled from a text file elsewhere (within the same domain name). This is because the message will change every couple of days or so and will therefore be updated on every page simultaneously (like an SSI).
Is it easy enough just to change the above bit of coding or will I have to paste the whole code here?
Can anyone help me please?
Look forward to hearing form someone.
I thought I would add the couple of lines above what I already posted as it may be of use.
I tried wwholemessage=("textfile.txt"); but this didn't work.
I am desperate to get this going... Anyone...Please!
****************
//scroller's speed: change to your own;
var wspeed=4
var wwholemessage=''
//text: change to your own
wwholemessage='<nobr class=tab>$28 US - This powerful BUNDLE: '+
'<a class=tabb href="#" onClick=\'window.top.location.href="http://members.rogers.com/bazil/"\'><u>Vertical SCROLLER with Recall V4.0 + Multiple Message Belt CONVEYER V4.0 + Multiple Message BLINKER V2.0</u></a></nobr>';
//-- end Parameters-->
//-- begin: Scroller's Algorithm -->
***************
joeframbach
01-07-2003, 01:18 PM
make a seperate .js file:
wwholemessage='<nobr class=tab>$28 US - This powerful BUNDLE: '+
'<a class=tabb href="#" onClick=\'window.top.location.href="http://members.rogers.com/bazil/"\'><u>Vertical SCROLLER with Recall V4.0 + Multiple Message Belt CONVEYER V4.0 + Multiple Message BLINKER V2.0</u></a></nobr>'
and put it in your page:
<SCRIPT language="javascript" src='foo.js"></SCRIPT>
and get rid of the wwholemessage='' and the other one in the html page.
Hi joeframbach
Thank you for your reply, but.....
Well, I have the script in the html page. That is a bit between the <head></head> and a bit in the <body></body> (and onload).
OK.
I understand that:
************
I make a seperate .js file:
wwholemessage='<nobr class=tab>$28 US - This powerful BUNDLE: '+
'<a class=tabb href="#" onClick='window.top.location.href="http://members.rogers.com/bazil/"'><u>Vertical SCROLLER with Recall V4.0 + Multiple Message Belt CONVEYER V4.0 + Multiple Message BLINKER V2.0</u></a></nobr>'
**********
And call it foo.js
****************
Where do I put
*****
<SCRIPT language="javascript" src='foo.js"></SCRIPT>
******
And then I will delete the wwholemessage='' and the other one that I have now put into foo.js
joeframbach
01-07-2003, 04:29 PM
put <SCRIPT...></SCRIPT> in the <HEAD>
Hey Joeframbach
Thank you again - but it didn't work!!! I am sure that it is me and not you! I'm not the best at all this..... OK I have the following code (all of it below) that I picked up from a javascript cut n paste site (I have removed some of the credits for now as it will take up too much room - the author's email address is in the code though!):
<!--Goes between <HEAD> & </HEAD> tags-->
<SCRIPT LANGUAGE="JavaScript">
//************************************
//* http://members.rogers.com/bazil/ *
// Vasile Birsan/Barsan *
//************************************
//-- Begin Scroller's Parameters -->
//scroller width: change to your own;
var wwidth=450
//scroller height: change to your own;
var wheight=20
//background color: change to your own;
var wbcolor="aqua"
//scroller's speed: change to your own;
var wspeed=2
var wwholemessage=''
//text: change to your own
wwholemessage='<nobr class=tab>$28 US - This powerful BUNDLE: '+
'<a class=tabb href="#" onClick=\'window.top.location.href="http://members.rogers.com/bazil/"\'><u>Vertical SCROLLER with Recall V4.0 + Multiple Message Belt CONVEYER V4.0 + Multiple Message BLINKER V2.0</u></a></nobr>';
//-- end Parameters-->
//-- begin: Scroller's Algorithm -->
var resumewspeed=wspeed
var sizeupw=0;
function startw(){
if (document.all) iemarqueew(wslider);
else if (document.getElementById)
ns6marqueew(document.getElementById('wslider'));
else if(document.layers)
ns4marqueew(document.wslider1.document.wslider2);
}
function iemarqueew(whichdiv){
iedivw=eval(whichdiv)
iedivw.style.pixelLeft=wwidth
iedivw.innerHTML='<nobr>'+wwholemessage+'</nobr>'
sizeupw=iedivw.offsetWidth
ieslidew()
}
function ieslidew(){
if (iedivw.style.pixelLeft>=sizeupw*(-1)){
iedivw.style.pixelLeft-=wspeed
setTimeout("ieslidew()",50)
}
else{
iedivw.style.pixelLeft=wwidth
ieslidew()
}
}
function ns4marqueew(whichlayer){
ns4layerw=eval(whichlayer)
ns4layerw.left=wwidth
ns4layerw.document.write('<nobr>'+wwholemessage+'</nobr>')
ns4layerw.document.close()
sizeupw=ns4layerw.document.width
ns4slidew()
}
function ns4slidew(){
if (ns4layerw.left>=sizeupw*(-1)){
ns4layerw.left-=wspeed
setTimeout("ns4slidew()",50)
}
else{
ns4layerw.left=wwidth
ns4slidew()
}
}
function ns6marqueew(whichdiv){
ns6divw=eval(whichdiv)
ns6divw.style.left=wwidth
ns6divw.innerHTML='<nobr>'+wwholemessage+'</nobr>'
sizeupw=ns6divw.offsetWidth
ns6slidew()
}
function ns6slidew(){
if (parseInt(ns6divw.style.left)>=sizeupw*(-1)){
ns6divw.style.left=parseInt(ns6divw.style.left)-wspeed
setTimeout("ns6slidew()",50)
}
else{
ns6divw.style.left=wwidth
ns6slidew()
}
}
//-- end Algorithm -->
</script>
<!-- End of Script between <head> & </head> tags-->
</head>
<body onload="startw();">
<!-- Make sure startw() is loaded -->
<!--Goes between <BODY ... > & </BODY> tags-->
<!-- begin: body code -->
<script language="JavaScript">
if (document.getElementById || document.all){
document.write('<div style="position:relative;overflow:hidden;width:'+wwidth+';height:'+wheight+';clip:rect(0 '+wwidth+' '+wheight+' 0);background-color:'+wbcolor+';" onMouseover="wspeed=0;" onMouseout="wspeed=resumewspeed">')
document.write('<div id="wslider" style="position:relative;width:'+wwidth+';height:'+wheight+';">')
document.write('</div></div>')
}
</script>
<ilayer width=&{wwidth}; height=&{wheight}; name="wslider1" bgcolor=&{wbcolor};>
<layer name="wslider2" width=&{wwidth}; height=&{wheight}; onMouseover="wspeed=0;" onMouseout="wspeed=resumewspeed">
</layer></ilayer>
<!-- end -->
</body></html>
Now. All of this is in the html page.
I need to get the 'message' put into a separate file (?foo.js?):
<nobr class=tab>$28 US - This powerful BUNDLE: '+......................
The idea is that although I put this scroller onto many pages (which will all call from the same 'message file'), the owners of the site can update the message as and when they want without me having to do anything. There will be a file upload page where they basically change the text and upload the file, which wil rewrite the file - this is all up and running (the file upload bit).
So, I am sorry to bother you again - perhaps I should have put the whole code into the post originally.
Your help would be so much appreciated.
Thank you in anticipation
Borgtex
01-07-2003, 06:27 PM
<SCRIPT language="javascript" src='foo.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
//************************************
//* http://members.rogers.com/bazil/ *
// Vasile Birsan/Barsan *
//************************************
//-- Begin Scroller's Parameters -->
//scroller width: change to your own;
var wwidth=450
//scroller height: change to your own;
var wheight=20
//background color: change to your own;
var wbcolor="aqua"
//scroller's speed: change to your own;
var wspeed=2
//-- end Parameters-->
...
Hello Borgtex
Thank you for your help!
OK. I did exactly as you said and....
I'm getting Javascript errors on the page:
Line135
Char: 1
Error: 'wwidth' in undefined
Code: 0
and
Line 93
Char: 1
Error: Object expected
Code: 0
******
Any ideas?
Thank you!
Borgtex
01-07-2003, 08:08 PM
Hummm
replace the code in foo.js file for: wwholemessage='Test message' and see if it works. If it does, check the quotes in the real wwholemessage (\' and things like that)
Hello again Borgtex!
Thank you for your help - I found the original problem - I copied over src "foo.js' instead of 'foo.js'
Now the background colour to the news scroller is there but there is no text - even using in the foo.js file:
wwholemessage='test message';
and
wwholemessage='test message'
The error code I am now getting is:
Line: 52
Char: 1
Error: 'wwholemessage' is undefined
Code: 0
***
This is harder than I ever imagined!
I do appreciate your help greatly ( and feliz aņo nuevo !)
IGNORE EVERYTHING!!!!
IT WORKS!!!!!
I used a ' instead of a " to define javascript as the language!
I amvery grateful to all assistance
Thank you very much
I am indebted to you!
Happy New Year
Feliz Aņo Nuevo
joeframbach
01-08-2003, 01:21 PM
sorry i couldnt fix that i was at school, then work :(
Hi joeframbach
Not a problem...
I have been using this site for a long time (prior to the name change) although I think I am still down as a newbie!
Anyway, it's the best forum for scripting on the web and long may it last.
Thank you to you and all others for their help...
I'll have a new problem soon, I'm sure!!!!
Thanks again.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.