Passing arguments between html pages is something that mostly has been used with CGI scripts and lately ASP pages but this is available for ordinary html files as well.
The secret is in the URL. Most web servers process the entire url and when a file is found the rest
of the path is passed along as an argument. For example the URL
points to the file
file.html in the virtual root of the web site. Passing the URL
http://www.myserver.com/file.htmlSomething will most likely result in a file not found error.
The secret is the
? (question mark sign) that isn't allowed in ordinary file names. Passing the
http://www.myserver.com/file.html?Something will load the file
the URL is still the entire string.
Taking advantage of this allows the web developer to look at the
window.location.href (it will
give the entire URL) and parse the text after the question mark. There is also a property called
window.location.search that just gives the text after the file.
These are the arguments that was passed to this page.
You could just add the arguments to the anchors you wrote in the document but that wouldn't be very dynamic. Another way is to set the location through scripting:
window.location = "filename.html?name=value"
The actual value could be calculated with some functions that were called due to user interactions.
Insert some arguments below:
There are a few basic tasks where this ability is really useful. The first I though of was in an image library. Clicking on a thumbnail launched a page with the image, description and some other common HTML. In this case you could just pass the image file name and the image description as arguments to the page and you would only need one file for the actual showing.
Another is download page. Today lot of sites takes you to a page with some info (and of course commercial) about the file and then refreshes with the file as url. Today these are done with cgi.
Frameset. You could pass the urls for the contained pages as arguments. This is useful when you want to use a frameset but need the entire page to change each time.
All of this can and is done today using CGI or ASP but not everyone wan't to learn CGI or have access to a server with ASP. This is copletely Client Side Scripting
Process the URL