tags:

views:

93

answers:

2

Is there a way to pass data between pages without using cookies and a server-side language in javascript? every way I found incorporates cookies or a server-side language (PHP session vars).

+3  A: 

You can pass it through a query string.

This link will give you the code to get it using JavaScript.

http://www.bloggingdeveloper.com/post/JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript.aspx

code snippet from the page:

function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}
Kevin
+1  A: 

You can always add data to the url query string when you navigate, like:

/site/page2?username=foo&bar=110

Of course you have to recognize that users can manipulate those values so some kind of validation will still be necessary when the new page loads and uses those values.

Mike Clark