Can HTML remember a keyword from 1 page to another?

R

Richard Marx

Hi, I want to set some keywords in one page, and then when a new window is
opened *from that page*, I want the keywords to be displayed.

E.g. I set the keyword in Page 1 as 'Mars', and when someone opens a link in
a new window from Page 1, I want the title of Page 2 to automatically
display, 'This planet is <PLANET>', so, 'This planet is Mars'.

Please advise, thanks!
 
G

Greg N.

Richard said:
E.g. I set the keyword in Page 1 as 'Mars', and when someone opens a link in
a new window from Page 1, I want the title of Page 2 to automatically
display, 'This planet is <PLANET>', so, 'This planet is Mars'.

This is easy to do with a server script langue like PHP.
With pure HTML it is not possible.
 
N

News

Richard Marx said:
Hi, I want to set some keywords in one page, and then when a new window is
opened *from that page*, I want the keywords to be displayed.

E.g. I set the keyword in Page 1 as 'Mars', and when someone opens a link
in a new window from Page 1, I want the title of Page 2 to automatically
display, 'This planet is <PLANET>', so, 'This planet is Mars'.

Please advise, thanks!

Can you set a temp cookie in the first page that the second page will read?
If the viewer jumps directly to the second page then you could have a
default for <PLANET> set
 
R

Richard Marx

Thanks, can you please elaborate on how to do this as you have time? I'm
not expert in the area of setting cookies.

:)
 
R

Richard Marx

Thanks, can you please elaborate on how to do this as you have time? I'm
not expert in the area of PHP either.

:)
 
D

David Dorward

Richard Marx wrote:

Please don't top post.
http://allmyfaqs.net/faq.pl?How_to_post
Thanks, can you please elaborate on how to do this as you have time? I'm
not expert in the area of PHP either.

First you need to make sure your server supports some server side
programming language. If it does, it might not support PHP, so I won't go
into detail on a specific language here.

However, what you are asking for is among the very first things are
typically taught in tutorials on server side programming, so find yourself
a tutorial for a language that your server supports and you should be up
and running pretty quickly.
 
B

Brian Cryer

Richard Marx said:
Hi, I want to set some keywords in one page, and then when a new window is
opened *from that page*, I want the keywords to be displayed.

E.g. I set the keyword in Page 1 as 'Mars', and when someone opens a link
in a new window from Page 1, I want the title of Page 2 to automatically
display, 'This planet is <PLANET>', so, 'This planet is Mars'.

Please advise, thanks!

You can do this with JavaScript. See
http://www.cryer.co.uk/resources/javascript/script8.htm to give you an idea.

There are a variety of reasons why this would be better done using server
side scripting, such as PHP, ASP etc. Go with server side scripting if your
host supports it. If your host doesn't give you scripting support (the
cheap/free ones tend not to) then JavaScript may be your only way forward.
 
G

Greg N.

Richard said:
Thanks, can you please elaborate on how to do this as you have time? I'm
not expert in the area of PHP either.

This is the calling page, (say, index.html):

<html><body>
<p>The following link will bring you to page2.php,
and pass the variable planet with the value "mars" to it.
<p>
<a href=page2.php?planet=mars>See how it works</a>
</body></html>

This is the called page (page2.php)

<html><body>
<?php $planet = $_GET['planet']; ?>
<h1>This planet is <?php echo "$planet"; ?></h1>
</body></html>
 
G

Greg N.

Bah, don't be so anal. If a post and the quote are all visible even in a
small window, top posting is perfectly OK.
 
R

Richard Marx

Greg N. said:
Richard said:
Thanks, can you please elaborate on how to do this as you have time? I'm
not expert in the area of PHP either.

This is the calling page, (say, index.html):

<html><body>
<p>The following link will bring you to page2.php,
and pass the variable planet with the value "mars" to it.
<p>
<a href=page2.php?planet=mars>See how it works</a>
</body></html>

This is the called page (page2.php)

<html><body>
<?php $planet = $_GET['planet']; ?>
<h1>This planet is <?php echo "$planet"; ?></h1>
</body></html>

Thanks Greg!
 
G

Greg N.

Richard said:
Thanks, how would you recommend I change it? I.e. which characters?

There is a security problem with that code if the PHP page (page2.php)
writes any data to a data base or to a flat file. It would allow a
hacker to sneak in data you don't want or expect.

If it is just your simple application that displays a picture of Mars or
something like that, I think you don't need to be concerned.
 
D

David Dorward

Greg said:
There is a security problem with that code if the PHP page (page2.php)
writes any data to a data base or to a flat file. It would allow a
hacker to sneak in data you don't want or expect.

If it is just your simple application that displays a picture of Mars or
something like that, I think you don't need to be concerned.

It is a security hazard anyway, since, as I mentioned previously, should a
third party be able to persuade a user to visit the site using a suitable
crafted URL then they can execute arbitrary JavaScript with the privileges
of that domain.
 
D

David Dorward

Greg said:
Bah, don't be so anal. If a post and the quote are all visible even in a
small window, top posting is perfectly OK.

A: Because everybody starts reading from the bottom.
Q: Why is top posting OK?
 
G

Greg N.

When post and quote are so small that you can grasp both without even
rolling your eyeballs, it's insignificant what's top and what's bottom.
At least for those with adequate reading comprehension.
 
G

Greg N.

David said:
...then they can execute arbitrary JavaScript
with the privileges of that domain.

Please explain: What are the potential privileges of a domain with
respect to JS?
 
D

David Dorward

Greg said:
Please explain: What are the potential privileges of a domain with
respect to JS?

Access to cookies is the obvious one (both reading and setting).
 

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,436
Messages
2,571,696
Members
48,796
Latest member
Greg L.
Top