This tutorial shows you how to create a StyleSheet changer using ASP, and a Cookie, without the need of Javascript.
The benefit of this is that if a user disables Javascript this script will still work, and should they have disabled cookies, then the default stylesheet will be used.
In the page to link to style
sheets, place this in head
<% If
Request.Cookies("StyleName") <> "" Then %>
<link
href="stylesheets/<%=Request.Cookies("StyleName")%>"
rel="stylesheet" type="text/css" />
<% Else %>
<link
href="stylesheets/styles.css" rel="stylesheet"
type="text/css" />
<% End If %>
'you need to change the
folder path to point to where you store your style sheets.
in separate asp file, place
<%
If
Request.QueryString("TextSize") = "Standard" Then
Response.Cookies("StyleName")="styles.css"
Response.Cookies("StyleName").Expires=Now+365
ElseIf
Request.QueryString("TextSize") = "Large" Then
Response.Cookies("StyleName")="larger_styles.css"
Response.Cookies("StyleName").Expires=Now+365
End If
%>
<%
Response.Redirect +
Request.QueryString("ReDirectURL")
%>
'you need to change the
style sheet names to reflect your own.
' save this page and call is
process.asp
use the following text in a
page to set cookie stylesheet
<p align="center" class="text"><a
href="process.asp?TextSize=Standard&ReDirectURL=<%=Request.ServerVariables("URL")%>">Standard
Text >></a> / <a
href="process.asp?TextSize=Large&ReDirectURL=<%=Request.ServerVariables("URL")%>">Large
Text >> </a></p>
You can add to the number of
stylesheets you use, simply by adding ElseIF 's to the process.asp page.
Of course to make it 100%
dynamic you can pass the style sheet name in the url when passing to the
process.asp page, and then not require the ElseIf’s
" Since graduating from university, I have worked with Charities and the Public sector, with my longest time being 3 years with the NHS until returning to freelance in 2003.
