Click to See Complete Forum and Search --> : Need to re-use JavaScript array


kandiyohiv
08-10-2003, 03:05 PM
I am using several JavaScript arrays which provide the values for a slide-show type display.

I would first like to detect the visitor's browser, and for those users with old browsers who wouldn't be able to view the slide-show correctly I would like to direct them to a browser-appropriate page which doesn't use the slideshow but would just list all array values.

Is there a way I can transfer my arrays to the new page so that the arrays don't need to be maintained in two places? Or, is there a way to split my page up into two sections and use an "if" or "goto" type statement that would say "If you have a new browser, use the slide-show. If not, go to the section labeled "OldBrowser" and display that code instead."

Or could the arrays be stored in a page all by themselves and then whenever I need to use them, I can just call for them?

Any help or different suggestions would be much appreciated.

xataku_nakusute
08-10-2003, 03:11 PM
i think your third idea is best.
all you have to do is write your script into an external .js file.

if you are unfamiliar with this, you do the following.

make a new text doc(if you have windows) and then write your javascript scripts in the text documnet, but exclude the <script></script> tags. then, save the document as blahblahblah.js, and upload it to your server.
on the pages you want the array to be on, type within the <HEAD> section of those pages-

<script src="path/to/your/blahblahblah.js"></script>

DO NOT type anything within the 2 script tags. if you need to, just make new script tags for any other scripts you need/have.

hope that helps!

kandiyohiv
08-10-2003, 03:26 PM
Thank you! Works great.