JavaScript and HTML Links

Hi everyone

I have two html files, file1.html and file2.html.

In file1.html, there is the following line:

<a href="file2.html?viewBook=file2.xml">File 2</a>

In file2.html, there is this section of code:

var options = {};
	options.playlistXmlPath = "playlist.xml";
	options.backColor = "FFFACD";
	options.firstColor = "0000FF";
	options.secondColor = "FF0000";
//	options.autoPlay = "true";
	options.autoPlayNext = "true";
	options.displayTime = "true";
	options.showStroke = "true";
	options.strokeColor = "006400";

What all this does is the user clicks on the link in file1.html, which obviously opens file2.html. The little bit of JavaScript shown is part of a Flash MP3 Player, and the line ‘options.playlistXmlPath = “playlist.xml”;’ is where I would like to be able to select different Playlists, depending on the link selected in file1.html.

As it stands at the moment, when the user clicks on the lin k above, the part of the link after the ? is ignored and the MP3 files in playlist.xml are played.

What I would like to know is how I can get the part of the above link after the ? into a JavaScript variable, so I can the use that variable in place of “playlist.xml” like this:

options.playlistXmlPath = newVariable;

I think what I am after is a JavaScript version of the PHP $_GET variable. There are quite a few variations already on the net that I have tried, but I cannot get them to work.

So any help would be greatly appreciated.

Hi, terrym
why not try hash?
change code in file1 as below:

<a href="file2.html[B]#[/B]viewBook=file2.xml">File 2</a>

and add this code in file2


Or leave it as ? and reference

Misusing the hash doesn’t make referencing it any easier.