Let's say that you want to select a random link within a certain div
tag which has a given id
and then jump to where that link points to. Here's a way to do that:
function random_link(id) { var obj = document.getElementById(id); var links = obj.getElementsByTagName("a"); var offset = Math.floor(Math.random() * links.length); document.location = links[offset].href; }