Random Target Of HREF

[Total: 0    Average: 0/5]

This shows how to have a link on your page that is random in it’s destination URL.

Body Code:

<script type=text/javascript>
var _a = new Array();
    _a[_a.length?_a.length:0] = "http://www.js-examples.com/";
    _a[_a.length?_a.length:0] = "http://www.js-examples.com/js/";
    _a[_a.length?_a.length:0] = "http://www.js-examples.com/consult/";
    _a[_a.length?_a.length:0] = document.location;
function loadNew() {
  var _t = _a[parseInt(Math.random()*_a.length)];
  //document.location = _t;
  document.exf1.t1.value = _t;
<a href="javascript:loadNew()">goto new random url</a>
<BR>This is where you would have gone:<BR>
<form name=exf1>
<textarea name=t1 row=1 cols=50 value="?"></textarea>

Times Viewed: 5

Leave a Reply

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