View Full Version : Pass a *.js file to a new page?

10-24-2005, 03:05 PM
Hi You All,

I'm still working on my tumbnail page.

On my catalog of pictures page I have a table with a list of page numbers.

I want to link each page to my tumbnail pages. Right now the code for each of the tumbnail pages is the same except for this one line of code in the <head> section.

<!-- ***** Javascript Section Starts Here ***** -->
<!-- *** Javascript variables for later use defined here *** -->

<script type="text/javascript" src="tnVariables1.js"></script>

<!-- *** End of Javascript variables definitions *** -->

<!-- ***** Javascript Section Ends Here ***** -->

Now I would like to be able to have each link on the "Catalog of Pictures" page go to the same page an pass the need variables stored in the matching *.js file.

On the "Catalog of Pictures page I have created an array with the URL of the *.js file.

var arrTNvariables = new Array();

Then assign each *.js file to the array arrTNvariable[i] = "path to file"
But how do I pass the arrTNvariable to the tumbnail page, and then use this variable to call the *.js file in the tumbnail page?


10-24-2005, 10:16 PM
I may have found the answer to my question.

I found the location.search function in my javascript reference book.

It looks like I can pass a string to my tumbnail page by adding it to the end of the URL of my < a herf> tag by preceding it with a ? for example

<a href="FavSlides/FavSlides_Pg01.htm?1">01</a>

This sends the string "?1" to my tumbnail page. There in the <head> section I can do this to pull the number out.

var num =(document.location.search.substring(1));

The "1" in the substring removes the "?" from the string that is passed. Then I can use the variable num that I created and assigned to construct the complete path to my *.js file that I want to use at this time.

I have not work all the coding yet, but the simple test code using document.write to see what is going on looks good.

I'm posting the answer to my own question here in case someone else does a search later looking for how to pass a variable value to another page.