encodeURI v. escape with a little IE7 kvetching thrown in

Jimminy Christmas Batman … not like the final release of IE7 yesterday isn’t going to break just about every CSS-driven faux, 3 column website in the land that doesn’t use clearfix

But I’m still dealing with a situation where some users on a site I’m developing are Mac MS IE 5.2 impaired!

Today’s challenge was to figure out a work-around to encoding a URI since pre-MSIE 5.5 browsers are sans the encodeURI function – and since I refuse to put out a tainted link on said site.

The solution? Detect if encodeURI exists and if it doesn’t, use the more deprecated escape function. As such:

/* javascript */
function MyEncodeURI(sBuf) {
sRet = sBuf;
try
{
sRet = encodeURI(sBuf);
}
catch(e)
{
sRet = escape(sBuf);
}
return sRet;
}

Simple enough, but bothersome enough as it took me forever to Google my memory to remember the try-catch approach in Javascript since no one else out there seems to be similarly afflicted with such sizeable issue with such a simple solution.Now if you don’t mind, I need to ‘prepare my sites for IE7‘ … even though one would think that the onus would be on MSFT to fix any w3c CSS not-so-compliant-issues that cause their new browser to gag-up like a kitty-choking on a furball.