It is possible to place random images & text on a webpage, but it will require the insertion of some JavaScript. Here’s how to do it: - Log into your administrative control panel
- edit the web page that you would like to modify (i.e. the “Home” page)
- when Page Builder displays your page click on the “source” tab at the bottom of the page
- Copy the code - when working with source code it it’s a good idea to copy the HTML and paste it into Note Pad or your favorite word processor. If the code becomes corrupted you can always go back to the original
- Place the JavaScript into the area that you want the random image displayed. You may want to experiment with the code first by placing it at the beginning of your HTML code.
- Click the Preview tab to preview the effects of the JavaScript.
Here is the JavaScript for random images. You can use the images in the code for testing and replace them with images you upload into your website: <script language="JavaScript"><!-- images = new Array(4); images[0] = "<a href = 'http://www.computerhope.com/index.htm'><img src='http://www.computerhope.com/banners/banner.gif' alt='Visit Computer Hope'></a>"; images[1] = "<a href = 'http://www.computerhope.com/history/index.htm'><img src='http://www.computerhope.com/banners/banner2.gif' alt='Computer History'></a>"; images[2] = "<a href = 'http://www.computerhope.com/index.htm'><img src='http://www.computerhope.com/banners/banner3.gif' alt='Visit Computer Hope'></a>"; images[3] = "<a href = 'http://www.computerhope.com/history/newslet.htm'><img src='http://www.computerhope.com/banners/banner5.gif' alt='Computer Hope Newsletter'></a>"; index = Math.floor(Math.random() * images.length); document.write("<DL>\n"); document.write("<DT>" + "" + images[index] + "\n"); document.write("</DL>\n"); // --></script>
Here is JavaScript for random text: <script language="JavaScript"><!-- text = new Array(4); text[0] = "Text 1"; text[1] = "Text 2"; text[2] = "Text 3"; text[3] = "Text 4"; index = Math.floor(Math.random() * text.length); document.write("<DL>\n"); document.write("<DT>" + "" + text[index] + "\n"); document.write("</DL>\n"); // --></script>
|