moose86
12-12-2009, 06:25 PM
hi all,
im looking for a script to allow random images to change but to have them as indervidual links that go to different places and also have them all going to different targets
e.g
image1.jpg > _blank
image2.jpg > _self
image3.jpg > _blank
image3.jpg > _blank
thanks in advance :)
jscheuer1
12-13-2009, 04:43 PM
<div id="randomLnks">
<a href="someDefault.htm" target="someDefaultTarget"><img src="someDefault.jpg" alt="Some Default Alt Text" title=""></a>
</div>
<script type="text/javascript">
(function(){
var imgLnkTrgs = [], targDiv = document.getElementById('randomLnks').getElementsByTagName('*');
imgLnkTrgs[0] = ['image1.jpg', 'http://www.somedomain.com/', '_blank'];
imgLnkTrgs[1] = ['image2.jpg', 'some.htm', '_self'];
imgLnkTrgs[2] = ['image3.jpg', 'http://www.anotherdomain.com/', '_blank'];
imgLnkTrgs[3] = ['image4.jpg', 'http://www.yetanotherdomain.com/', '_blank'];
imgLnkTrgs = imgLnkTrgs[Math.floor(Math.random() * imgLnkTrgs.length)];
targDiv[0].href = imgLnkTrgs[1];
targDiv[0].target = imgLnkTrgs[2];
targDiv[1].src = imgLnkTrgs[0];
targDiv[1].alt = 'Random Image w/Link';
})();
</script>
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.