Random HTML display?

Discussion in 'HTML' started by Gaffer, May 4, 2004.

  1. Gaffer

    Gaffer Guest

    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
    Gaffer, May 4, 2004
    #1
    1. Advertising

  2. Gaffer

    Neal Guest

    On Tue, 4 May 2004 22:27:06 +0100, Gaffer <>
    wrote:

    > 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
    Neal, May 4, 2004
    #2
    1. Advertising

  3. Gaffer

    Gaffer Guest

    "Neal" <> wrote in message
    news:eek:...
    > On Tue, 4 May 2004 22:27:06 +0100, Gaffer <>
    > wrote:
    >
    > > 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
    >
    >


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

    _____
    Gaffer
    Gaffer, May 4, 2004
    #3
  4. Gaffer

    Neal Guest

    On Tue, 4 May 2004 23:16:34 +0100, Gaffer <>
    wrote:

    >
    > "Neal" <> wrote in message
    > news:eek:...
    >> On Tue, 4 May 2004 22:27:06 +0100, 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? No HTML solution, but

    >> Javascript can do this. See
    >> http://www.w3schools.com/js/tryit.asp?filename=tryjs_randomlink

    > 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.
    Neal, May 4, 2004
    #4
  5. Gaffer

    Gaffer Guest

    "Neal" <> wrote in message
    news:eek:...
    > On Tue, 4 May 2004 23:16:34 +0100, Gaffer <>
    > wrote:
    >
    > >
    > > "Neal" <> wrote in message
    > > news:eek:...
    > >> On Tue, 4 May 2004 22:27:06 +0100, 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? No HTML solution, but
    > >> Javascript can do this. See
    > >> http://www.w3schools.com/js/tryit.asp?filename=tryjs_randomlink

    > > 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.
    >
    >


    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
    Gaffer, May 4, 2004
    #5
  6. Gaffer

    Neal Guest

    On Tue, 4 May 2004 23:27:11 +0100, Gaffer <>
    wrote:


    >> >> http://www.w3schools.com/js/tryit.asp?filename=tryjs_randomlink

    >
    >
    > 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.
    Neal, May 4, 2004
    #6
  7. Gaffer

    Gaffer Guest

    "Neal" <> wrote in message
    news:eek:...
    > On Tue, 4 May 2004 23:27:11 +0100, Gaffer <>
    > wrote:
    >
    >
    > >> >> http://www.w3schools.com/js/tryit.asp?filename=tryjs_randomlink

    > >
    > >
    > > 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.
    >
    >


    Hi again,

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

    Thanks

    _____
    Gaffer
    Gaffer, May 4, 2004
    #7
  8. Gaffer

    C A Upsdell Guest

    "Gaffer" <> wrote in message
    news:MUTlc.365$dl3.252@newsfe1-win...
    > 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.
    C A Upsdell, May 4, 2004
    #8
  9. Gaffer

    Neal Guest

    On Tue, 04 May 2004 22:48:25 GMT, C A Upsdell
    <cupsdell0311XXX@-@> wrote:

    > 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.
    Neal, May 4, 2004
    #9
  10. Gaffer

    Gaffer Guest

    "Neal" <> wrote in message
    news:eek:...
    > On Tue, 04 May 2004 22:48:25 GMT, C A Upsdell
    > <cupsdell0311XXX@-@> wrote:
    >
    > > 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.
    >
    >

    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
    Gaffer, May 5, 2004
    #10
  11. Gaffer

    Juha Suni Guest

    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

    More information about PHP at comp.lang.php

    --
    Suni
    Juha Suni, May 5, 2004
    #11
  12. "Juha Suni" <> wrote in message
    news:4098a08a$0$16602$...
    : 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.

    --
    Long
    www.webcharm.ca - Integrated content management web hosting
    Long - CM web hosting, May 5, 2004
    #12
  13. Neal wrote:
    > On Tue, 4 May 2004 23:27:11 +0100, Gaffer <>
    > wrote:
    >

    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. "
    Disco Octopus, May 6, 2004
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren Clark

    Random NOt random?

    Darren Clark, Jun 24, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    453
    mikeb
    Jun 24, 2004
  2. Maziar Aflatoun

    Random not really random...

    Maziar Aflatoun, Aug 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    26,699
    Maziar Aflatoun
    Aug 5, 2004
  3. Marek Kurowski
    Replies:
    1
    Views:
    993
    Mark A. Odell
    Aug 18, 2004
  4. globalrev
    Replies:
    4
    Views:
    756
    Gabriel Genellina
    Apr 20, 2008
  5. VK
    Replies:
    15
    Views:
    1,161
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page