Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 9 of 9
  1. #1
    Junior Member
    Join Date
    Sep 2006
    Posts
    5
    Member #
    13966
    Hello all,
    My question is this: rather than having a web page with buttons that link off to other pages, could you use buttons to simply reload a new style sheet?
    That way you would only have one page, with all your divs in, and by opening different style sheets you would select how the page would look? Could this be done so that it standards complient? If so, how?
    Thanks
    Andy Jones

  2.  

  3. #2
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    You could do that using something like PHP, or JavaScript (although I'm not sure how you'd do it that way).

    What you do is create your buttons, but make them link to the same page (this is with PHP by the way). You put an extension to the URL on the end, like this: [minicode]http://site.com/index.php?style=1[/minicode].

    In your script you take that extra bit added on and do something like this:

    PHP Code:
    <?php

    $style 
    $_GET['style'];

    if (empty(
    $style)) {
    $style "something";  // Name of default stylesheet, without extension
    }


     echo 
    "<link rel='stylesheet' href='" $style  ".css' type='text/css' />";

    ?>
    Numbers don't have to be used, you just change the bit after '?style=' so it's the name of the stylesheet you want to load.

  4. #3
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    This could be modified to use buttons instead of links.. http://www.codelifter.com/main/javas...ngestyles.html

    Read This: http://www.quirksmode.org/dom/changess.html

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    While something like this would work, by the way, it's rather unadvisable due to the fact that it'll likely be slow and will be a huge bandwidth hit -- you'll be transferring all of the content even if your user is only interested on part of it.

  6. #5
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,693
    Member #
    5580
    Liked
    717 times
    Andy ...

    With PHP dynamically creating pages, that is sort of what PHP "includes" do.

    See this site where each page is just a PHP include that is specified by
    a page number: http://www.palosantodesigns.com/

    If you mouse over the links on the left, look at the URL for those links.
    The site owner has access to the text files that the PHP script uses in
    it's "includes". They edit those files to make changes on various pages.

    There's no reason that you couldn't also have a .css style sheet for each page.

    Since PHP is dynamically loading each page (just like any other webpage),
    it would actually be the same bandwidth and everything ... the same as
    loading a different page somewhere else.


  7. #6
    Junior Member
    Join Date
    Sep 2006
    Posts
    5
    Member #
    13966
    Hello all, thank you for your contributions,
    I have tried using the method LJM suggested, and it works perfectly, except I have to upload it to see it working! I was thinking, that all the images and everything would be loaded when you first view the page, but only some elements would be visible, so that when I swap style sheets only part of the page needs to reload?
    But instead the whole thing reloads. Is there away to get it like using frames, I.E only one frame relaods?
    Thanks everyone
    Andy Jones

  8. #7
    Senior Member solidgold's Avatar
    Join Date
    Jun 2006
    Posts
    766
    Member #
    13373
    on a unrelated note, you dont happen to be andy jones chemistry teacher do you?
    sorry if this isnt you!
    solidgold

  9. #8
    Junior Member
    Join Date
    Sep 2006
    Posts
    5
    Member #
    13966
    haha, no I'm not a chemistry teacher.

  10. #9
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Yes, ljm's methodology uses server-side includes, which requires that the browser do a round-trip to the server to get the changes. The information bfsog pointed you to should assist you in getting a non-reloading implementation done.

    Though if you want to avoid reloads, your best bet is probably AJAX.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:59 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com