New Revised CSS Library Forums Web Tools
FAQs Awards Usage Terms Contact
Categories
Other Sections
Sweet Ads
Compatibility
Bookmark online:

FF1+ IE5+ Opr7+

Ajax Rotating Includes Script

Author: Dynamic Drive

Note: Updated Dec 14th', 05 to fix bug related to calling the script multiple times on a page.

Description: This is a shakeup of the Ajax Includes script to let you input a list of external pages for the script to choose and selectively include one onto the current page. Three types of inclusion are supported:

  1. Daily 1 ("dailyw"): The script will include a different file for each day of the week (Monday, Tuesday, etc).
  2. Daily 2 ("dailym"): The script will include a different file for each day of the month (1st to 31st).
  3. Random ("random"): The script will randomly pick one from the list of files to include.

You can call the script multiple times on the same page, each with a different inclusion type. Note that due to inherent limitations, the included files MUST be from the same domain as the page doing the inclusion.

Demo (Display type used below is "dailyw", or different file for each day of the week):


Directions Developer's View

Step 1: Insert the below script to the HEAD section of your page:

Select All

Step 2: Once that's done, to include an external page, use the below code in the BODY section of your page where you want the external file to be included:

<script type="text/javascript">
ajaxinclude(includefiles, "dailym")
</script>

Where "includedfiles" is the name of the array in the code of Step 1 that contains your list of files, and "dailym", the inclusion type. For the inclusion type, the 3 valid values are:

  1. "dailyw": The script will include a different file for each day of the week (Monday, Tuesday, etc). As such you must specify 7 files inside your array, one for each day of the week starting Monday.
  2. "dailym": The script will include a different file for each day of the month (1st to 31st). As such you must specify 31 files inside your array, one for each day of the month.
  3. "random": The script will randomly one pick from the list of files to include.
As mentioned in the description for the script, you can call this script (code of Step 2) multiple times on your page, each with a different array list and inclusion type. Enjoy!