W3C home > Mailing lists > Public > www-svg@w3.org > October 2003

Re: svg with http paramter

From: Gavin Kistner <gavin@refinery.com>
Date: Mon, 6 Oct 2003 12:12:55 -0600
Cc: www-svg@w3.org
To: Alfred Tsang <atsang@ic.sunysb.edu>
Message-Id: <B557CAB6-F828-11D7-AEDC-0003937E984E@refinery.com>

On Wed 10 Sep 2003, Alfred Tsang wrote:
> Is it possible to pass a parameter to svg from http GET method?
> for example, http://localhost/somesvg.svg?foo=bar, how can I access 
> foo?

Here's some code which, included on your page, will create a new 
keyVals object which can be accessed either by index of 
(case-sensitive) key name.

if (/\?(.+)/.test(document.URL)){
	var keyVals=window.keyVals=RegExp.$1.split('&');
	for (var i=0,len=keyVals.length;i<len;i++){
		var pair=keyVals[i].split('=');
} else window.keyVals={};

//For example, with:
alert(keyVals[0]); // 'bar'
alert(keyVals.jimmy); // 'jammy'
alert(keyVals.objID+1); // '111'

Note that with the last, all values coming from the querystring are 
type string; to use them as numbers, you need to make them such, like:

alert(keyVals.objID*1 + 1); //12

Gavin Kistner @ Refinery, Inc.
work: +1.303.444.1777
cell: +1.303.641.1521
Received on Monday, 6 October 2003 14:12:58 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:46:57 UTC