View Full Version : Simple JS Question

01-31-2004, 06:49 PM
I have begun renovation of an old website of mine, and I would like some help. I hope to include a "random quote" bar to the side of each page. No problem. I have coded the array and random number and display properties, and everything works fine.

However, as I have it now, the quote array (about 30 quotes so far) is included in the code for each page I wish to include the random quote bar on. This works, but of course makes adding new quotes difficult since I have to go through each page and put them in again and again. I do know Java, but I have very little experience with JS, and I was wondering what JS syntax would give me the ability to access my large quote array from a single file, which I could easily add to seperately. This would allow me to add a quote to this seperate file and as a result each page with the "random quote" function would be able to retrieve the new quotes from that file.

Can JS do this?

01-31-2004, 07:40 PM
Sure, just make your script into an external file.

<SCRIPT type="text/javscript" SRC="http://www.mypage.com/myscript.js"></SCRIPT>

Make sure that your external script doesn't have the script tag in it and save it with the .js extension.

01-31-2004, 07:43 PM
what he says, use virtual paths instead of absolute one though.

01-31-2004, 07:48 PM
perfect. that makes things much easier.

thanks for the help fellas.

03-02-2004, 11:53 AM
Thanks for this thread - I'm not as clear on JS as I should be, and I didn't know how to make a script external:o !

03-03-2004, 01:21 AM
If you are just starting off in javascript, head over to w3schools.com and check out their tutorial.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum