NS6+ IE5+ Opera 7+
Random Content Order script
Updated: Sept 21st, 07 to support randomizing
Description: Randomize the display order of arbitrary content on your page with this script! As a result, the order in which the participating contents is displayed on the page changes randomly each time the page loads. This script is useful when you wish to give certain contents equal visibility on the page, so no one content always occupy the top spot.
Simply wrap the desired contents in DIV containers with a shared CSS
Demo: There are five ordinary content below. Reload page to see their display order randomized each time:
Step 1: Insert the following script in the HEAD section of your page
Step 2: Insert the below sample code into the BODY section of your page:
The code of Step 2 illustrates how to apply the script to ordinary content on your page- simply wrap the participating content inside a DIV tag with a common "class" attribute:
At the very end, call function "
You can also use this script on TABLE rows to randomize their
display order. Just give the participating
<table border="1" width="100%">
1) As mentioned, to group abitrary content on the page to be randomized, you give every content the same CSS class name. You're free, however, to give certain individual content within this group additional class names to style that content differently from the rest- just separate multiple class names with a space:
Here we have 3 contents that will be randomized as a group, with the 2nd and 3rd content each carrying an additional class attribute.
2) You can call "
3) Depending on the type of content you wish to randomize on the page, you may want to call function "randomizeContent()" after the page has fully loaded (instead of instantly) to prevent any problems: