Server Side javascript. - TechRepublic
General discussion
March 19, 2002 at 01:22 AM
trebleclef81

Server Side javascript.

by trebleclef81 . Updated 24 years, 2 months ago

Hi, I basically want to make a program that will rotate advertisements randomly (picture and hyperlink) in all my web pages. For this, I need to load the advertisements into an array and basically select a random item from that array. To avoid having to add all the data into each and every web page, I’d want to load my array up from a file, on the server. So, my problem is: “How do I load up a Javascript array with data that is in a file? Thank you your help is greatly appreciated and valued. I have this for now, and it is not getting interpreted as server side because when I check the source code, the code (other than the tags) is there.

Content-type: text/html\n

x = new File(“source.txt”);
fileIsOpen = x.open(“r”);

if (fileIsOpen)
{
while (!x.eof())
{
for (var i = 0; i < 3; i++) { pic[i] = x.readln(); } for (var i = 0; i < 3; i++) { linker[i] = x.readln(); } for (var i = 0; i < 3; i++) { compnay[i] = x.readln(); } for (var i = 0; i < 3; i++) { linkwords[i] = x.readln(); } for (var i = 0; i < 3; i++) { lastwords[i] = x.readln(); } } }

This discussion is locked

All Comments