The index page of the site I'm working on has three different versions, and Management (truly a proper noun, in this case) wants one version displayed 50% of the time, and the second and third versions each displayed 25% of the time. It needs to be done with JavaScript, which makes me really sad; I know it'd be simple, elegant, and easy with PHP, and we'd get to avoid pesky browser bugs and people with JavaScript disabled. Without any chance of using server-side scripting, we're doomed to the client. Oh well.

Since I want the index page to work with JavaScript disabled, I devised the following code. (The JavaScript may not be the most beautiful thing ever, but I'm a programming newbie and it was the best I could do. I'm sort of proud of it. )

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">	
	<link href="style.css" rel="stylesheet" type="text/css">
	<script type="text/JavaScript">
	// create random number: 1, 2, 3, or 4
	var random_number = (Math.ceil(Math.random() * 4));

	// loads page depending on random_number's outcome, without breaking back button
	switch(random_number) {
		case 1:
		case 2:
		case 3:
		case 4:
	// -->
	<!-- all HTML between body tags in original page1.html file,
so they miss out on the random page stuff, but still get the one we wanted them to see 50% of the time anyway -->
I thought that browsers wouldn't render anything between noscript tags if JavaScript were enabled. This works fine in Internet Explorer 6.0, Netscape 6.2.1, Mozilla 0.9.7, Netscape 4.78, Lynx 3.2, and a little WebTV viewer on Windows 2000. In Opera 6.0, though, and on my graphic designer co-workers' IE 5.0 for Macintosh, the noscript content is flashed on the screen for a moment before the JavaScript randomizer thing actually runs and takes them to page1.html, page2.html, or page3.html. It doesn't look very good, and I think it's because a) Opera 6.0 renders pages really, really fast, and b) because those designers have huge new Macintoshes of unimaginable power, so that IE 5 renders pages really, really fast. But they shouldn't be displaying what's between the noscript tags anyway, right?

Is there a better way to display a random page with JavaScript and still make it friendly for people with JavaScript disabled?

Thanks a lot.