Monday, October 31, 2011

Forwarding Webpages with JavaScript

Here is a simple javascript that will randomly forward you to either yahoo (50% of time) or google (50%). This could be used for split testing websites.


<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">

<!--

//-->

var i = Math.round(100*Math.random());

if (i<=50) { window.location="http://www.yahoo.com"; } if (i>50)

{

window.location="http://www.google.com";

}

</script>

0 comments: