Jump to content

question


Striped Fish

Recommended Posts

Yes! Using javascript or a server-side script like PHP. Here's a quick javascript example. Notice that if javascript is not enabled (not likely, but it happens), after 2 seconds, the meta-refresh still takes the user to the page of your choice.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"   "http://www.w3.org/TR/html4/strict.dtd"><html>	<head>		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">		<meta http-equiv="refresh" content="2;url=http://www.coca-cola.com">		<title></title>		<script type="text/javascript">			var page_array = new Array();			// these can be extended indefinitely just by following the pattern			page_array[0] = "http://www.disney.com";			page_array[1] = "http://www.coca-cola.com";			page_array[2] = "http://www.adobe.com";			page_array[3] = "http://www.google.com";			var i = Math.floor (Math.random() * page_array.length);			location = page_array[i]; 		</script>	</head>	<body>		<p>Please wait . . .</p>	</body></html>

PHP would be faster, but only if you have access to that.

Link to comment
Share on other sites

If you have access to PHP use something like this:<?php$variable_name = rand(1, 4);if ( $variable_name == 1) { header( 'Location: http://www.yoursite.com/page_name.html' ) ;}if ( $variable_name== 2) { header( 'Location: http://www.yoursite.com/page_name.html' ) ;}if ( $variable_name== 3) { header( 'Location: http://www.yoursite.com/page_name.html' ) ;}if ( $variable_name== 4 ) { header( 'Location: http://www.yoursite.com/page_name.html' ) ;}?>-make sure no html is outputted before this script--change variable_name to whatever you want to name the variable--change "http://www.yoursite.com/page_name.html" in each if statement to your page address-hope this helps. :]

Link to comment
Share on other sites

Try one of these: [i'm not sure if it's correct, but I gave it a shot, if it doesn't work tell me and give me your error code]using set urls:

<%dim random_number, minimum, maximumminimum = 1maximum  = 4random_number = Int((max-min+1)*Rnd+min)if  random_number = 1 thenResponse.Redirect "http://www.yoursite.com/page_name.html"end ifif  random_number = 2 thenResponse.Redirect "http://www.yoursite.com/page_name.html"end ifif  random_number = 3 thenResponse.Redirect "http://www.yoursite.com/page_name.html"end ifif random_number = 4 thenResponse.Redirect "http://www.yoursite.com/page_name.html"end if%>

using variables:

<%dim random_number, minimum, maximumdim url1, url2, url3, url4minimum = 1maximum  = 4random_number = Int((max-min+1)*Rnd+min)url1 = http://www.yoursite.com/page_name.htmlurl2 = http://www.yoursite.com/page_name.htmlurl3 = http://www.yoursite.com/page_name.htmlurl4 = http://www.yoursite.com/page_name.htmlif  random_number = 1 thenResponse.Redirect (url1)end ifif  random_number = 2 thenResponse.Redirect (url2)end ifif  random_number = 3 thenResponse.Redirect (url3)end ifif random_number = 4 thenResponse.Redirect (url4)end if%>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...