Random HTML display?

G

Gaffer

Hello

Is there a way in which I can make certain parts of Html on my website
random so that each viewer will see different material if they refresh the
page or come back onto the website later? I am currently using the
"<!--#include virtual="cgi-bin/menu1.txt" -->" command to display my menus
on every page of my site, so that the same material is shown on every page,
and I would like a way that I can randomize this perhaps.

Any suggestions appreciated.

_____
Gaffer
 
N

Neal

Hello

Is there a way in which I can make certain parts of Html on my website
random so that each viewer will see different material if they refresh
the
page or come back onto the website later? I am currently using the
"<!--#include virtual="cgi-bin/menu1.txt" -->" command to display my
menus
on every page of my site, so that the same material is shown on every
page,
and I would like a way that I can randomize this perhaps.

Any suggestions appreciated.

_____
Gaffer

No HTML solution, but Javascript can do this. See
http://www.w3schools.com/js/tryit.asp?filename=tryjs_randomlink
 
N

Neal

That looks like it will work, thanks a lot mate. :)

Just remember, if JS is off, it won't work, so test it w/o Js running to
be sure that gives you an acceptable result.
 
G

Gaffer

Neal said:
Just remember, if JS is off, it won't work, so test it w/o Js running to
be sure that gives you an acceptable result.

Hi again

I've noticed that if I paste what I want randomized into one of the
"document.write" in that JavaScript it comes up as "done, but with error" in
the browser. I don't think it works for tables, only text and html. I still
might be able to use it though.

_____
Gaffer
 
N

Neal

I've noticed that if I paste what I want randomized into one of the
"document.write" in that JavaScript it comes up as "done, but with
error" in
the browser. I don't think it works for tables, only text and html. I
still
might be able to use it though.

I'm not much with Js, so I ought not advise you much further, but it would
seem to me it should be possible to write any text to the document and
have it work. If you use " in your included text, that will cause
problems. I'm not certain how to escape that character in a Js seting.

If I were you, I'd inquire in a javascript ng only after consulting the
tutorial at the above site for the solution.
 
G

Gaffer

Neal said:
I'm not much with Js, so I ought not advise you much further, but it would
seem to me it should be possible to write any text to the document and
have it work. If you use " in your included text, that will cause
problems. I'm not certain how to escape that character in a Js seting.

If I were you, I'd inquire in a javascript ng only after consulting the
tutorial at the above site for the solution.

Hi again,

I have posted my request in the JS ng, so hopefully someone will reply soon.

Thanks

_____
Gaffer
 
C

C A Upsdell

Gaffer said:
Hello

Is there a way in which I can make certain parts of Html on my website
random so that each viewer will see different material if they refresh the
page or come back onto the website later? I am currently using the
"<!--#include virtual="cgi-bin/menu1.txt" -->" command to display my menus
on every page of my site, so that the same material is shown on every page,
and I would like a way that I can randomize this perhaps.

Any suggestions appreciated.

Navigational menus generated randomly? How interesting for the user.
 
N

Neal

Navigational menus generated randomly? How interesting for the user.


It was my assumption that he would be randomizing some other content. But
it would be disastrous to randomize the navigation, indeed.
 
G

Gaffer

Neal said:
It was my assumption that he would be randomizing some other content. But
it would be disastrous to randomize the navigation, indeed.
Not the navigation, but some tables containing image links (advertisements)
that would randomize and a user could possibly see something he hasn't
before.

_____
Gaffer
 
J

Juha Suni

Gaffer said:
Is there a way in which I can make certain parts of Html on my website
random so that each viewer will see different material if they
refresh the page or come back onto the website later? I am currently
using the "<!--#include virtual="cgi-bin/menu1.txt" -->" command to
display my menus on every page of my site, so that the same material
is shown on every page, and I would like a way that I can randomize
this perhaps.

This is something that is very easy to do with any server-side language.
The advatange of server-side scripting is the independece from the
clients browser or settings. I assume most hosts these days support
either PHP, ASP or both (unless you are using a free space provided by
your ISP).

For PHP I would use:

<?php
$number = rand(1,3);
include('cgi/bin/menu' . $number . '.txt');
?>

To include either menu1.txt, menu2.txt or menu3.txt

More information about PHP at comp.lang.php
 
L

Long - CM web hosting

: Gaffer wrote:
: > Is there a way in which I can make certain parts of Html on my website
: > random so that each viewer will see different material if they
: > refresh the page or come back onto the website later? I am currently
: > using the "<!--#include virtual="cgi-bin/menu1.txt" -->" command to
: > display my menus on every page of my site, so that the same material
: > is shown on every page, and I would like a way that I can randomize
: > this perhaps.
:
: This is something that is very easy to do with any server-side language.
: The advatange of server-side scripting is the independece from the
: clients browser or settings. I assume most hosts these days support
: either PHP, ASP or both (unless you are using a free space provided by
: your ISP).
:
: For PHP I would use:
:
: <?php
: $number = rand(1,3);
: include('cgi/bin/menu' . $number . '.txt');
: ?>
:
: To include either menu1.txt, menu2.txt or menu3.txt
:
Simple enough. There might be a problem with getting a more realistic
random number though. It seems the rand() function is generating a new
seed each time the page is access. Perhaps I am mistaken.
 
D

Disco Octopus

If you use " in your included text, that
will cause problems. I'm not certain how to escape that character in
a Js seting.

escape with a backslash

eg...
"\"" will produce a single double quote. "
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top