Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Swap CSS file...

Status
Not open for further replies.

bobindy

Technical User
Apr 9, 2003
1
US
Hello,

I want to give the user the ability to change font sizes on a page. In theory this seems like simply swapping out one CSS file for another but I'm not sure where to start.

Thoughts anyone?

You can see this in action at:

Thanks,
Bob
 
Sounds like you may want to use PHP, and do conditional includes of the CSS (or just font tags)... then you can drop in a form on each page, and even allows you the option of using a cookie to let the user keep their theme each time they return to your site (with that browser on that machine).
 
Thats more or less what I did for virtually the same thing heres the code


<!-- form to allow users to select ctyle theme-->
<form action='set-theme.php' method=POST >
<Option>---- Colours ----</option>
<Option value=&quot;choice1.css&quot;>Black/white</option>
<option value=&quot;choice2.css&quot;>Grey/Blue</option>
<option value=&quot;choice3.css&quot;>White/Black</option>
</select>
<input type=&quot;submit&quot; Value=&quot;Select&quot;>&nbsp;
<input type=&quot;reset&quot; value=&quot;Reset &quot;>
</form>




<!-- set-theme.php -->
<?php
setcookie(&quot;style&quot;,$_POST[theme],time()+1209600);
Header(&quot;location:main.html&quot;);
?>


<-- all pages on site note pages need to be saved as page.php not page.html -->

<?php
if (isset ($HTTP_COOKIE_VARS[&quot;style&quot;])) $mystyle = $HTTP_COOKIE_VARS[&quot;style&quot;];
else $mystyle=&quot;choice1.css&quot;;
echo&quot;<html><head><link rel=StyleSheet href=\&quot;{$mystyle}\&quot; type=text/css media=screen>&quot;;?>
<title>Page Title</title>
</head><body></body></html>

hope this helps
Ian Infinity exists! - I just haven't worked out a way to get there yet.

| |
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top