Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Random Stylesheet Type question

    Hi Guys

    I'm working on my companies website at the moment. I've been making sites for a while, but I've never gotten into CSS style sheets or any real coding stuff. Basically, I want to have maybe 3 different coloured versions of the site, with a different picture for each, and have it so that when you visit the site you randomly see one of the 3. They'll be identical apart from the colour scheme and picture. You can view the site here:

    http://free-st.t-com.hr/nfje/aps/

    If anyone knows how to code a simple index.htm page that will randomly direct you to, say, index_green.htm, index_red.htm or index_blue.htm I'd be forever grateful. I've read on some of the posts here that CSS is the way to go but I really haven't a clue where to start.

    Cheers

    Sam

  • #2
    New to the CF scene
    Join Date
    Dec 2005
    Location
    Rotherham, UK
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you able to use PHP on your server?

    If so, you could solve the problem through a little PHP command.

    PHP Code:
    <?php

    $css 
    rand(02);

    if(
    $css === 0){
      echo 
    '<link rel="stylesheet" type="text/css" href="/sylesheet1.css" />';
    }

    elseif(
    $css === 1){
      echo 
    '<link rel="stylesheet" type="text/css" href="/sylesheet2.css" />';
    }

    else{
      echo 
    '<link rel="stylesheet" type="text/css" href="/sylesheet1.css" />';
    }

    ?>
    Replace the 'href' bit with a link to whatever stylesheet you are using and place the above code inside the <head> tags of your website.

    I hope that works, it seemed to when I tested it.

    PS Sorry if that shouldn't have been posted in this forum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •