SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2000
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Based on a selection, I want to reload the current page changing only the stylesheet call. What is the best approach, CGI or JavaScript?

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you got PHP on your server thats probably the easiest way (if an NT server it'd be Cold Fusion)

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>
    &lt;link rel="stylesheet" href="&lt;? print("$name"); ?&gt;.css"&gt;
    [/code]

    Now what the above bit is doing is loading up a style sheet dynamically depending on user input. If thats not what you wanted then you would change it, pass several variables like color, size, font, etc and then fill them each in separately into your style (which would have to be included into the header). To make that little bit of code work just rename your page with a .php3 extension and you're good to go (assuming your server supports it).

    Now your form is just gonna be a post form pointing to the php3 document and it'll all work.

    Chris

  3. #3
    SitePoint Member
    Join Date
    Jul 2000
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With Javascript you dont have the load on the server + searchenginges go throught it.
    There are several ways to achieve changing with js. One of the more flexible ones would be to do a page.html?style=xxx,
    parse it with js and do a conditional document write which loads an external js which writes the stylesheet.

    parsing scripts are at www.javascriptsource.com

    and the external js would be just be
    document.write ('&lt;STYLE&gt;') ....


Bookmarks

Posting Permissions

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