views:

41

answers:

5

Hi All,

In HTML do we have any variable which can be accessed in all pages similar to Sessions Variables in ASP.NET ?

I have a Querystring value in welcome.HTML and I want that value in complete.htm

User can't go directly to complete.htm from welcome.htm as there are other pages in between those pages.

Regards msbyuva

+1  A: 

You'll want to use client-side cookies (by employing JavaScript) because HTML is not a server-side language the way ASP is, etc.

LesterDove
Thanks for your reply.. In my case it may not work as Users may Disable the Cookies which would be problem. Is there any asking the User to Enter a value and send that value in QueryString ?
msbyuva
Hi. Only if you have some type of server-side page in between to read the Qstring variable (asp, php, cgi, whatnot.) No way that I know of with plain HTML. (If so, I've been working way too hard! Ha.)
LesterDove
+1  A: 

Not without HTML5: http://playground.html5rocks.com/#sessionstorage

(As mentioned, Cookies is a good alternative)

Kirk Woll
Thanks for your reply.. In my case it may not work as Users may Disable the Cookies which would be problem. Is there any asking the User to Enter a value and send that value in QueryString ?
msbyuva
You can always chain together a value from one page to another as long as you continue to include that value in the query string every time. Definitely a pain, but doable. You could do something similar with hidden fields if navigation to every page consisted of an HTTP POST instead of GET. Again, not ideal.
Kirk Woll
A: 

Hi, in welcome.html, use javascript to get querystring value, assign it to a form value and post it to complete.htm using form post or get method

Osman Kelle
Thanks for your reply.. Could you provide me any sample code .. ?It helps me !!
msbyuva
long time ago I wrote this code. Solution guaranteed :) It takes my time unfortunately.
Osman Kelle
A: 

With HTML supported in browsers today, you don't have variables. You can have Javascript set a cookie, though.

Dean J
A: 

Global variables don't exist in HTML--these are just static pages of code. In order to pass a value from one page to another you can only use cookies (which you are concerned of users disabling, thus making them useless), the querystring, or a form post. Querystring can be set either by modifying the link to pages or by using a form with the get method.

Since welcome.HTML does not have a direct link to complete.htm, you will need to find a way to continuously pass the variable from page to page until complete.htm is reached. The simplest solution in this case is probably to use JavaScript to modify each link to each page in your sequence of links to include the QueryString on each link, until complete.htm is reached.

Russ