Random – Odds Of New Window 1 in 200

[Total: 0    Average: 0/5]

This shows how to have a new window open on a chance of 1 in 200 page views.

Body Code:

<script>
var odds=Math.random()*200; // odds is a float type.
var newWin = null;
if (odds <=1 ) {
  newWin = window.open();
} else {
  document.write("your number was "+odds);
}
</script>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *