Results 1 to 3 of 3

Thread: Need to re-use JavaScript array

  1. #1
    Join Date
    Aug 2003

    Question Need to re-use JavaScript array

    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.

  2. #2
    Join Date
    Jul 2003

    the third idea..

    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!

  3. #3
    Join Date
    Aug 2003

    Works great!

    Thank you! Works great.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center