Top.Mail.Ru
? ?
Javascript's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Saturday, May 14th, 2005

Time Event
3:27p
Is it okay to do this?
I have been wondering... How do I pass on some data to a html file given that cookies are disabled on the client's computer, and the server does not support scripting - PHP, Perl, CGI, etc. ??? The problem has to be solved on the client's side.

Let's say we have two files: p1.htm and p2.htm. The JavaScript in p1.htm wants to load p2.htm into the browser. But p1.htm needs to pass certain values to p2.htm. How do you do it?

Here is what I found:

p1.htm will load p2.htm and insert the data into the address field like this:

location.href = 'p2.htm#mydata123';

The JavaScript function in p2.htm will read the "location.href" variable and remove everything that precedes the '#' sign. What's left is "mydata123"!!!

This way, I can pass parameters from one file to the next.

My question is, IS THIS 'LEGAL'?

What the script is doing here is basically tell the browser to load p2.htm and go to LABEL mydata123. Of course, there is no such label in p2.htm, so the browser will just go to the beginning of the page.

<< Previous Day 2005/05/14
[Calendar]
Next Day >>
About LiveJournal.com
Image