Re: Send parameter from one HTML page to another?

Martin Honnen wrote:
Petar Popara wrote:

Is it possible to send one parameter from one HTML page to another
HTML page? For example: to send some data as part of the link from
first page:

and second page could receive "mydata" in JavaScript.

You can access various parts of the location object, in the above case
would be the string
which you could then parse e.g.
would give you the mydata string.
If you use the usual query string format to pass data e.g.
then check various script archives for code that parses that query
string, it has been done certainly.

This function returns the ith parameter, starting at parameter 0
function qsobj(parm)
var qpairs ="&")
var qvbl = qpairs[parm].split("=")
return qvbl[1] ? unescape(qvbl[1].replace(/%20|\+/g," ")) : null

I use it like this
<a href = "picture.html?pic=image.jpg&cap=name of

picture.html has this code
<script type="text/javascript">
var pic = qsobj(0)
var cap = qsobj(1)
var height = qsobj(2)
var width = qsobj(3)

Other JS code in picture.html uses the variables

As I understand it, the variable names passed do not have to match the
variable names used when they are retrieved.
That is the call could just as well be
<a href = "picture.html?p=image.jpg&c=name of picture&h=600&w=400">

Trevor L.


Relevant Pages

  • A general solution
    ... Split on an array of delimiters; parse a file in one call. ... Hi Gerry,If the string is using comma to separate name and using quotation ... var element; ... Gerry Hickman wrote: ...
  • Re: Calculate the string statement
    ... verkn:(vkn:char; ... funkt:(fkt:string; ... var fkt,dfkt: p; ... var fehler: boolean; ...
  • Two new tests for MM B&V
    ... var RunningThreads: Integer; ... class function TStringThreadTest.GetBenchmarkDescription: string; ... function CheckPattern(const Dest: Pointer; const Size: Integer; const ...
  • server-side JavaScript: Prototypes of built-in classes, objects and functins
    ... Session object (disk-based session variables for data persistence ... File class (manipulation of files on server, ie. open, close, read, ... //Methods Cgi.queryCgi.postCgi.anyby default return an empty string if requested var not found ...
  • Re: [PHP] Image Generation
    ... the text, font, colour, maximum frame size (ie the width and height it ... var $xoffset, $yoffset, $margin; ... a string or array of strings. ... a float or an array of floats - which size to display the related text at. ...