Find said:
I initialize a variable named cpag = 'recommend this page'
in another external script page I will use: cpv = cpag
But it does not work, only if cpag is initialize on the same page as
cpv = cpag.
???
Hi,
If I understand you well, you make a variable on one page in js, and
wonder why it is not on the next page. Is that right?
If so: ALL variables have a scope of 1 page: the page they live in.
When the page reloads, or is replaced, you loose all your js variables.
And that is good.
Imagine your browser should keep track of all variables that ever
existed in js....
If you want to pass a variable around, you have several options.
1) cookie
Set a cookie. This only works if the pages are in the same domain.
2) pass around via GET in the URL, like this in a hyperlink:
<a
href="
http://www.example.com/yourscript.html?cpag=recommend this page">Visit
another page</a>
That works to every page, also outside your domain.
yourscript.html can now extract the value of cpag out of the url.
And a few more options, but these 2 are the most simple to implement I
expect.
Regards,
Erwin Moller