»
EnglishFrenchVietnamese

Print - Random Objects - JavaScriptBank.com

Full version: jsB@nk » Misc » Random Objects
URL: https://www.javascriptbank.com/random-objects.html

Random Objects © JavaScriptBank.comThis JavaScript will display randomly the objects on the different positions.

Full version: jsB@nk » Misc » Random Objects
URL: https://www.javascriptbank.com/random-objects.html



JavaScript
<script>//1) Specify content(s) to display and rotate//   You can specify multiple "sets", each displayed in diff. areas of your pagevar content=new Array() //sample set 1content[0]='<a href="http://JavaScriptBank.com"><img src="../image/logojs.gif" border=0></a>'content[1]='<a href="http://echip.com.vn"><img src="../image/photo3.jpg" border=0></a>'content[2]='<a href="http://JavaScriptBank.com"><img src="../image/logojs.gif" border=0></a>'var diffcontent=new Array() //sample set 2diffcontent[0]='<a href="http://www.google.com">Google Search Engine</a>'diffcontent[1]='<a href="http://news.bbc.co.uk">BBC News</a>'diffcontent[2]='<a href="http://www.msnbc.com">MSNBC News</a>'function randomorder(targetarray, spacing){var randomorder=new Array()var the_onevar z=0for (i=0;i<targetarray.length;i++)randomorder[i]=iwhile (z<targetarray.length){the_one=Math.floor(Math.random()*targetarray.length)if (targetarray[the_one]!="_selected!"){document.write(targetarray[the_one]+spacing)targetarray[the_one]="_selected!"z++}}}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<script>//2) Call function randomorder(arrayname, space_between_content)randomorder(content, '<br><br>')randomorder(diffcontent, '<br>')</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->