Skip to main content

How to randomly displaying images on page refresh

This script display images in "imageRot" div randomly on every page load.

Replace "quote-xx.gif" with your image name.



<div id="imageRot"></div>
<script type="text/javascript">
var images = new Array();
images.push("quote-01.gif");
images.push("quote-02.gif");
images.push("quote-03.gif");
images.push("quote-04.gif");
images.push("quote-05.gif");
images.push("quote-06.gif");
images.push("quote-07.gif");
var random = Math.floor(Math.random() * 7);
var imageRot = document.getElementById("imageRot");
imageRot.innerHTML = '<img src="images/' + images[random] + '" alt="">';
</script>

Comments

Popular posts from this blog

Using javascript to Include a html file inside another html file

When there is no server side functionality needed we create the whole site in plain html. Usually these sites have left/right side menu, top header, footer etc.. If the site grows in to 20, 30 pages, it will be a headache to do a simple change like changing footer text. We will have to change each page. If we were using a server side technology like PHP, JSP, etc.., we will have the chance to keep the common areas in the site in different pages and include these parts in each page using a “include” statements. We can do the same thing with the plain old html and javascript. But how? First you need to create the site main layout using divs and give them unique ids. <html> <title>HTML Includes</title> <script language="javascript" src="js/main.js"></script> <script src="js/prototype.js" type="text/javascript"></script> <script language="javascript" xml:space="preserve"> // <...

New Lost Season Rocks !!!!!

New Lost season started on ABC network last Tuesday. In last two seasons they introduced time travel. Now it seems they are talking about parallel universe theory. They say this is going to be there last season of the long running amazing TV show. "The aftermath from the detonation of the hydrogen bomb is revealed."

Adding custom validations to WSO2 Enterprice Store - Publisher asset creation page.

Writing an asset extension Asset extensions allows to create custom functionalities and look and feel to a certain asset type in WSO2 Enterprise Store. With this example, I am going to create a new asset type and add a custom validation to the asset creation page. Download WSO2ES product distribution from wso2.com and extract it to your local drive. Start the server and fire up browser with the admin console url. https:// :9443/carbon/ Navigate to Extensions > Configure > Artifact Types and click the "Add new Artifact" link. This will load the UI with a new default artifact. Notice that it has following attributes in it's root node. shortName="applications" singularLabel="Enterprise Application" pluralLabel="Enterprise Applications" "applications" is the name of new asset type we are going to add. In our example we are going to do a custom validation to the asset creation page. ...