Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: Re: FLASH: Semi off topic Javascript question...
From: Colin Moock
Date: Fri, 13 Nov 1998 16:58:36 +0000 (GMT)

flasheratshocker [dot] com,Internet writes:
>Sorry about this off topic JavaScript question, but since it is
>something going on my flash site and I know there are a bunch of JS
>studs on this list.... I thought I'd ask it here...

>I was just wondering if there was a way to pass information in a form on
>"HTML page A" to a form on "HTML page B" using Javascript (and maybe a
>cookie here or there)? And if so how?

Yup, one approach is to use cookies. So, you'd have your form call a
javascript function (using either the "ONSUBMIT" handler of the FORM
element or the "ONCLICK" handler of an INPUT TYPE="BUTTON" element). In
that function, you'd do whatever you want to do, and also set the
cookie like this:

window.document.cookie = "your_cookie_name = " + yourvar;
or
window.document.cookie = "your_cookie_name = your_cookie_value";


Then, on the next page, you'd read the cookie into a variable like this:
if (window.document.cookie != "")
{
var your_cookie = document.cookie;
your_cookie = your_cookie.substring((save.indexOf("=")+1),save.length);
}

The code above does this:
1) First checks if the cookie exists.
2) If it does, assigns the whole thing to "your_cookie".
3) Parses the value of the cookie (you don't want the whole thing, you
just want what it's set to. Eg. if you had a cookie that was "foo =
barbaz", you'd just want to use "barbaz". The parsing line looks for
the "=" sign, and takes everything after the character after it up to
the end of the cookie text.


Another approach to your problem would be to handle the system with a
hidden frame. So you'd have a main frame that shows your first and
second pages, and a hidden frame that contains your javascript. When
you submit your form on page one, you set a javascript value in your
hidden frame, and load page two into your main frame. So you've changed
the page that the viewer sees, but you haven't actually loaded a
complete new document into the browser, so all your javascript
variables are still accessible.

For reference, here's how to make a borderless hidden frameset on all
browsers.

<HTML>
<HEAD><TITLE>Your Title Goes Here</TITLE></HEAD>
<FRAMESET ROWS="100%,*" FRAMEBORDER="0" BORDER="0" FRAMESPACING="0">
<FRAME NAME="main" SRC="mainpage.html" FRAMEBORDER="0"
BORDER="0" FRAMESPACING="0">
<FRAME NAME="hidden" SRC="hiddenpage.html" FRAMEBORDER="0"
BORDER="0" FRAMESPACING="0">
</FRAMESET>
</HTML>

Have fun!

colin moock


------------------------------------------------------------------------
To UNSUBSCRIBE send: unsubscribe flasher in the body of an
email to list-manageratshocker [dot] com. Problems to: owneratshocker [dot] com
N.B. Email address must be the same as the one you used to subscribe.
For info on digest mode send: info flasher to list-manageratshocker [dot] com



Replies
  FLASH: Semi off topic Javascript questio, Gomez, Steve

[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]