Here's a simple code written with jQuery, you can customize it to work with any element (iframe, div, etc) and you can use it several times by giving the elements different classes:
HTML Code:
<!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">
<title>Random iframe</title>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js">
</script>
<script type="text/javascript">
/*Edit below*/
var w = 'iframe'; //what is randomized?
var c = 'random'; //class of random items
var n = 4; //number of items
/*Edit above*/
$(function(){
$(w + '.' + c).css({
'display': 'none'
});
var title = w + '.' + c + '[title="' + Math.ceil(Math.random() * n) + '"]';
$(title).css({
'display': 'block'
});
});
</script>
<style type="text/css">
iframe.hidden {
display: none;
}
</style>
</head>
<body>
<iframe title="1" class="random hidden" src="http://www.google.com/">
google
</iframe>
<iframe title="2" class="random" src="http://www.dynamicdrive.com/">
dynaimc drive
</iframe>
<iframe title="3" class="random hidden" src="http://www.yahoo.com/">
yahoo
</iframe>
<iframe title="4" class="random hidden" src="http://www.w3c.org/">
w3c
</iframe>
</body>
</html>
This one works in all browsers and if the user has JavaScript turned off, the iframe without the hidden class will show, so the users will always see an iframe. Good luck!
Edit: It seems John was quicker, but I'll leave the script here since I believe it could be useful to other people since it's much easier to use and customize than John's.
Bookmarks