|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
General - Question - Masking QueryStrings;
Hi all,
I gave my website a much needed re-design recently and have tried to make it as accessible as possible. One feature I have is to allow the user to increase text size by clicking buttons at the top right of the main content. (can be seen here ) Anyways as you can see it just passes a QueryString that then selects what stylesheet to use since its all done with percentages. The question I have is, can the QueryStrings be masked? Not just for the user but also for search engine spiders as now when I check my Google analytics, index.asp, index.asp?WhatSize=Small, index.asp?WhatSize=Medium... etc etc are all indexed as seperate pages. Have I gone about this the wrong way? Or is it just one of those things that I just need to accept? (p.s. I didnt want to use JavaScript to do it because I wanted the website to work on any browser whether JavaScript is disabled or not) Thanks, Liam |
|
#2
|
|||
|
|||
|
I would not recommend that you pass that through the querystring. Use javascript, not that many people are going to want to change the size of the font anyways.
__________________
"You'll never be as perfect as BLaaaaaaaaarche." |
|
#3
|
|||
|
|||
|
Hi thanks again for reply!
I have been playing about tonight and tried another method. Instead of passing a QueryString from page to page, when you click the buttons to change font size, it goes to an asp only file that then changes a variable in the global.asa file (first time using global.asa believe it or not). The user then gets redirected back to the page from which they clicked and they have the new text size. I thought I had is sorted! But then I noticed a problem. The variable is shared between each user. So if one person clicks to have bigger text, everyone else seems to have it to. Can I stop that? |
|
#4
|
||||
|
||||
|
you're at a lose lose situation here....you do not want to use javascript because of on/off issues...yet you are relying on cookies....which too is based on user browser settings....
so...IMO...if you are worried about if a user not having js enabled...then chances are that user knows how to set their own font settings in their browser...(ctrl-mouse scroll) for example...btw...works great on your site...that's a good thing as far as the current problem...i imagine the word "global" would have set off alarm bells...
__________________
Please give respect to those that helped solve an issue by clicking on the reputation icon
|
|
#5
|
|||
|
|||
|
Thanks for reply.
Yeah I sort of realised that as well. What's the difference between relying on cookies being enabled or javascript being enabled... The one good thing about using cookies though would be that if the same person came back to my site after months or even years, I would be able to detect what their proffered text size was and display that size of text from the start. I was going to create a cookie detection and if the user had cookies disabled, then a warning would appear next to the buttons they click to make text bigger/smaller. Anyways I think I will just use small simple forms and solve the problem that way. No hassle with cookies, and no ugly querystrings. Thanks for your replies, Liam |
|
#6
|
|||
|
|||
|
I found this website http://www.yha.org.uk/ that manges to do it. They don't Javascript and use cookies like I was trying to.
To change the text size they use a querystring but when you go browsing through website, they querystring is dropped, yet the text size stays your preferred size. Is there any way to view their global.asa file? |
|
#7
|
||||
|
||||
|
Hi,
I may be wrong, but I guess that they achieve this by using session variables. If the page recieves a querystring variable it sets a session variable to the desired text size. Each page then uses the value of this session variable. If you select another text size, the value is passed in the querystring and over-writes the value of the session variable. Code:
If Len(Trim(Request.Querystring("textsize"))) > 0 Then Session("textsize") = Trim(Request.Querystring("textsize"))
|
|
#8
|
|||
|
|||
|
HI,
Is the session variable unique to each visitor then? So for instance if a user chooses to have the large text, another user at the other side of world wont have the same large text when he/shee browses the site? Thats what was happening when I tried using the global.asa file. Im at my work just now so cant remember what the exact code I used was, but it was something like: Application("TextSize") But with using that, every user got the same text size. Thanks, Liam |
|
#9
|
||||
|
||||
|
The session is uinque for each user, check this out:
http://www.w3schools.com/ASP/asp_sessions.asp |
|
#10
|
||||
|
||||
|
something to nibble on...not purty,,,but may give you an idea
general cookies...not session click me Code:
<%
Function GetFontSize(sFontSizeSel)
Response.buffer = True
Select Case sFontSizeSel
Case "small", "medium","large"
Response.Cookies("FontSize") = sFontSizeSel
Response.Cookies("FontSize").Expires = Date + 365
GetFontSize = Request.Cookies("FontSize")
Case Else
sFontSizeCookie = Request.Cookies("FontSize")
If Len(sFontSizeCookie) > 0 Then
GetFontSize = sFontSizeCookie
Else
'default
GetFontSize = "small"
End If
End Select
End Function
%>
<html>
<head>
<style type="text/css">
body {font-size:<%=GetFontSize(Request.QueryString("font-size"))%>;}
a {color:blue;}
span.small {font-size:small;}
span.medium {font-size:medium;}
span.large {font-size:large;}
</style>
</head>
<body>
<a href="?font-size=small"><span class="small">A</span></a>
<a href="?font-size=medium"><span class="medium">A</span></a>
<a href="?font-size=large"><span class="large">A</span></a>
<p>This is some text to test font cookie</p>
</body>
</html>
Last edited by keep_it_simple : May 12th, 2008 at 10:03 PM. Reason: link....made as a general cookie vs session...stateful |
|
#11
|
|||
|
|||
|
Thanks sync_or_swim and keep_it_simple for your help.
I was way over complicating things. For some reason I had it in my head that the only way I was going to get this to work is by doing something in the global.asa file. But that was completely un-true! Believe it or not I use sessions for log-in areas. And even though I dont have a global.asa file, sessions created when logging in works fine. So I have did exact same thing now. When you clcik one of those buttons, it changes the Session("TextSize"). All I needed was to create a session on each users computer so they have control over their text size and no one elses. I cant believe how much of a puzzle I managed to get myself into! I will add a quick line of code that will pass a querystring back if session was not changed due to cookies being disabled and dispaly a message stating that. Now I have created this session, I take it it lasts around 20 minutes if there is no actions from the user? To increase that to lets say and hour, I will have to put that in the global.asa file yes? Code:
Sub Session_OnStart
Session("TextSize").Timeout = 60
End Sub
The cookie way of doing it taht you just gave me keep_it_simple does seem like a better option though as if the user ever did return to the website, he/she would automatically get their preffered text size so I will give that a go tonight. And from the global.asa file I can also see how many users are on the website at a time? Im joking, I'm not away to get into that just yet ![]() (I have tested it by opening a few different browsers and making sure changing the text size in one doesnt effect the text size in the other and everything seems ok but for some reason I am still paranoid that I'm overlooking something). |
|
#12
|
||||
|
||||
|
Quote:
You're welcome, glad it helped. With regards the session timeout, did you check out the link I posted? You just need to specify the number of minutes to increase the session timeout to, like this: Code:
<% Session.Timeout=60 %> Last edited by sync_or_swim : May 13th, 2008 at 05:52 AM. |
|
#13
|
||||
|