PDA

View Full Version : Alternate to CGI Redirection for drop-down list box javascripts


allen
14-Mar-2003, 03:17 PM
Hi all,

I'm having a problem where my search scripts are redirecting to the root of the site instead of the acatalog directory using a javascript derived from the drop-down list box javascripts in the advanced user guide.

Unfortunately this project is very near completion and the client wants to see a demo, so I 'knocked up' the following javascript:


var re = /^(.*)\?SECTIONID=/;
var uridec = decodeURI (ar[i].sURL);
uridec = uridec.replace (re, "");
re = /&NOLOGIN=1$/;
uridec = uridec.replace (re, "");
var thispage = location.href;
re = /index\.html$/;
thispage = thispage.replace (re, "");
re = /\/acatalog/;
if (!re.test (thispage)) {
uridec = "acatalog/" + uridec;
}


This takes the long cgi url (from the Act_Sections.js file) and converts it to a short direct url.

Yes, it may be a bit messy, but my javascript is a little rusty, so I tend to do things a bit of a longer way round, but it works :)

Javascript is such an awful language - it's far too easy to get it wrong (but still have it sort of work) and far too laborious to get right.

I've run this through both Mozilla 1.2.1 & IE 5.5 SP2 with no errors.

Allen