I am working on a pretty big project here at the office. I’m creating a static HTML demo version of our application. This is not the easiest task I’ve been given since I started with Banklink. There is so much server side dynamic processing, that is some instances, a single ASP page has resulted in the creating of 4 HTML pages. To make the process of capturing the pages as smooth as possible, I’m using client side JavaScript to handle browser redirection. Let me give you an example.

Image we have a page, foo.asp that could be rendered four different ways. The determining factor as to how the page in rendered is based on a querystring value, ‘type’. The first obstacle I had to overcome was how to direct the browser to the correct version of foo.asp. So, I changed the calling page link from foo.asp to foo.htm, but kept the querystring values. Then I created a new HTML page called foo.htm. This page is responsible for redirecting the browser to the proper HTML page. Next, I saved each version of foo.asp as foo.ver1.htm, etc.

Inside foo.htm I us a helper function to parse the querystring client side. The querystring is a property of the window.location object, window.location.search ( ask my buddy Mark Andreason why it’s ‘search’ and not ‘querystring’, asshole! ). So, this is what’s in foo.htm

<script language="javascript">
 var type = QueryString("type");

 switch (type)
  case "A":
   url += '.ver1.htm';
  case "P":
   url += '.ver2.htm';
  case "I":
   url += '.ver3.htm';
  case "X":
   url += '.ver4.htm';

 window.navigate( '/html/' + url );


and this allows for pseudo-redirection so the demo user has the impression that they’re looking at dynamic content.

Of course, this project was due the day before it was assigned, so I’m a wee bit busy today. Gotta go! 🙂