Web Analytics Made Easy -
StatCounter different website versions with random css - CodingForum

Announcement

Collapse
No announcement yet.

different website versions with random css

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • different website versions with random css

    Hello everybody !!!
    I have a question... I know I should work on my problem before posting it here, but I've no clue where I should begin....
    I want to load random versions of my website, but I don't want to make all my pages again for each version. I thought about having external css links, and activate each link depending on the version. But I don't really know how to do this. I use frames on my main page, and I also have an image, which will change depending on the version.
    If you want to have a look at it, here's my website : Les Enfants de l'ش
    For the main page, I don't mind making different versions, but for the links, I don't want to have 3 ( or more ) different pages ( one for each version ). Can you help me with my problem ? Is javascript the right language for that ???
    Thanx a lot !!! Psychophage ( sorry for my english, it's not my maternal language )

  • #2
    Use Javascript

    You can use javascript to load the related css file..do as follows :

    In the head section of your site, add the following code..

    if CONDITION
    document.write "<LINK rel='stylesheet' href='style.css'>"
    else
    document.write "<LINK rel='stylesheet' href='style2.css'>"

    etc...

    Hope this helps
    Matt Sartain
    Internet Solutions Developer
    - Zonecom Communications

    Comment


    • #3
      Yeah, I thought about doing something like that, but I'm not too sure about the condition. How does it detect which version it is supposed to load ? Can I do something that would check the main page version, and then load the corresponding css ?
      Thanks a lot for your suggestion !

      Comment


      • #4
        well 3 ways of getting vars from main page.


        1. if it is frame site u can store the vars in the frame html file and all files will subsequently be able to get it by
        parent.VARNAME;

        2.if it ain't frame u can set the style to be passed with all ur links
        LINK?style=theme. this would then mean u would have to get the style of the link on your pages.

        3. if your server support some server language(php,asp,etc) and supports session for this language u can session the style theme and print it to the link tag on the server.

        Comment


        • #5
          I use frames... So, I've to put all the styles in the main frame page ?
          How can I do this ?
          Sorry, I'm really a beginner, so I need a lot of help.... I understand css and html very well, but I just started to learn javascript..

          Comment


          • #6
            what if I do it with a conditional statement ?
            Let's put it in words :
            If parentversion = version1, load css1
            elsif parentversion = version2, load css2
            esle load css3
            would something like that work ???
            I'm just a beginner, so I don't know much about the script...
            How can I detect the parent version ? I actually mean, the main page of my site.. I plan to do three ( or more ) different main pages, but I don't want to make three different versions for each page, even if this means only changing a css link...
            So I would like to have one page, which would load the right css, depending on which was the main page....
            pleaaaassssee !!!!!
            I need help badly...

            Comment


            • #7
              Example of how to do it in the zip file
              Attached Files

              Comment


              • #8
                thanks, Garadon !!!!
                But what is the main.html file for ?
                How do you put this in frames ?
                And how do you make that the version loaded is different, depending on what is the mainpage ?

                Comment


                • #9
                  the main.html is your main page.

                  it sets a variable in the frameset with
                  parent.styleSheet='1.css'

                  all files then have this line in them

                  document.write('<LINK REL=stylesheet HREF="'+parent.styleSheet+'" TYPE="text/css"> ')

                  and in the frameset page you have this

                  <script>
                  var styleSheet='1.css';
                  </script>

                  Comment


                  • #10
                    great !!!! I'll work this out, and I'll tell you if it worked. Thanks a lot for your help !!!!!

                    Comment


                    • #11
                      Hi !!!!!!!!
                      it's me again......
                      Thanks to you, I manage to do the things with the css ( relative to the parent ), but I have one more question :
                      In my frameset, when I open a page ( for example, page 1 ) in the mainframe, it's working without problem. But then, if, from page 1 ( which is now in the mainframe ), I want to open another page ( page 2, whose link is on page 1 ), it doesn't work any more... The page 2 opens itself as target:_self on top of the page 1, but is still in the frameset.... So do you have a solution for that ? Is it possible to open a page from another page in the frameset, and this page would still have its style defined by the frameset ?
                      Hope you understand what I mean, because I realise I'm not really THAT clear....

                      Comment


                      • #12
                        assuming you using the code I gave you,

                        then this put in any page that are loaded in the frameset should work
                        document.write('<LINK REL=stylesheet HREF="'+parent.styleSheet+'" TYPE="text/css"> ')

                        Comment


                        • #13
                          Yeah, it should work.... But it doesn't.... Don't know why.....
                          You know, the page which is loaded in the frameset is ok, and your code works great for every page that is loaded in the mainpage, but then, if I have some links on a page ( which is loaded in the mainframe ), that open in another page ( still in the frameset ), by the target: _self method, it doesn't load the css, and I get the default css from the browser ( white and very ugly page ). Do you konw how to fix it ?

                          Comment


                          • #14
                            ooh, it worked, finally.....
                            The pages were in a different folder, maybe that's why it didn't work. Now is everything fine, thanks a lot !!!!!!

                            Comment

                            Working...
                            X