Avoid HTML Special Characters in Your Querystring CodeUnit 13 MAR 2010

I must admit, I was totally left scratching my head a couple of days ago while presenting a survey capturing site I had just finished whipping up, when all of a sudden the site stopped redirecting properly when tested in Internet Explorer (IE) using compatibility mode. Completely flummoxed as to why something that worked perfect fine in some browsers simply didn’t work in others, I stopped to have a quick peek at what might be causing the problem and when I saw what it was, I couldn’t help but break out into laughter.

In order to redirect my script after successfully pushing data into the database, I was using Javascript to change the window’s location to a URL I was specifically building up with some required GET variables attached. However, my ordering of variables in the querystring couldn’t have been more unfortunate had it tried – you see, I was using a variable entitled reg and attaching it to the URL as &reg.

Now those of you with sharp eyes and a little bit of HTML knowledge will immediately slap your heads and go “duh” out loud, because yes, I had managed to accidentally declare a reserved HTML special character, namely ® which is of course translated to the registered trademark symbol. So my querystring was still working but with one less required GET variable as it was being lost in the redirect thanks to the older browser translating it into the actual symbol – hence causing that extreme sense of head-scratching puzzlement I had experienced earlier!

So be a pal and check your variable order in your querystrings carefully. You never know what you might inadvertently creating! :)

Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.