two script pages

F

Find Clausen

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.

???
 
E

Erwin Moller

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
 
F

Find Clausen

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?

No, it's not like that:

It's like in the tread:
Including one external JS file directly into another ...

just two-three variable form the main file would not be "assigned" in
the included file.

But I have now moved it all to the language file, so no sweat :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top