The Digital Research Initiative The University of North Carolina at Chapel Hill ![]() Transmogrification Engines Below are two really cool scripts that I developed to randomize specific objects of a webpage. The scripts produce a random number, and depending on that number, display an image or text that has been assigned to that number. Then, to see a different object, hit reload and the scripts spits out a new one. Very dynamic, very cool, very posh. This first one uses the date to produce a random number. Then it says, "Okay, if the number I just made is greater than this number, then display this." This script goes between your <body> tags wherever you want the cool effect to go. An example of it in action follows.
Transmogrifier at work:
This next engine is my favorite; I use this one all the time. It's a lot more flexible and lets you have more than just eight randomized objects. It's broken up into two separate sections. The first part goes between the </title> and the </head> tags. The second part goes inbetween the <body> tags, wherever you want the randomized object to show up. That keeps your page's source code from getting too messy. This part goes in the <head> tags. You set the number of objects where you see even[0]. This is your array, and you can have as many evens as you want. Make sure you start off at [0]. Then, when you're finished added objects, add them up and put the number between the () at makeArray thing. But be careful. Even though it starts off at [0], you count it as one. The next object, labeled [1], is your second object. Here the objects go to [2], so that means you've got a total of 3 objects.
This part goes inbetween <body> tags, wherever you want the object to show up.
This engine at work:
|