Showing posts with label Web Development. Show all posts
Showing posts with label Web Development. Show all posts

11/18/2009

Display Images Randomly on my web page





If you want to display images randomly, one at a time in your web page you can use the following html code.

First you should put this code inside the head tag


<
HEAD>

<
SCRIPT language="javascript">
function RandomImageLong(images,iparams)
{
si = 0;
ci=0;
cc=0;
imageSet = new Array();
ei = images.length;
for (i=1;i if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
imageSet[cc] = images.substring(si,i);
cc++;
si=i+1;
}
}
ind = Math.floor(Math.random() *cc);
document.write("<
img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\">");
}

function RandomImage(images)
{
RandomImageLong(images," ");
}

function RandomImageLinkLongTarget(images,urls,iparams,hparams)
{

imageSet = new Array();
urlSet = new Array();
si = 0;
ci=0;
cc=0;
ei = images.length;
for (i=1;i if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
imageSet[cc] = images.substring(si,i);
cc++;
si=i+1;
}
}
ind = Math.floor(Math.random() *cc);
si = 0;
ci=0;
cc=0;
ei = urls.length;
for (i=1;i if (urls.charAt(i) == ' ' || urls.charAt(i) == ',') {
urlSet[cc] = urls.substring(si,i);
cc++;
si=i+1;
}
}

document.write("<
a "+hparams+" href=\""+urlSet[ind]+"\"><
img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\">");
}

function RandomImageLinkLong(images,urls,iparams)
{
RandomImageLinkLongTarget(images,urls,iparams,"");
}

function RandomImageLink(images,urls)
{
RandomImageLinkLongTarget(images,urls,"border=0","");
}

<
/SCRIPT>
<
/HEAD>

Then you should put the following code inside the body and the place where you want to display the image

<
BODY>

<
SCRIPT>

RandomImageLong("image1.jpg image2.jpg image3.jpg image4.jpg ","width=152 height=136");

<
/SCRIPT>
<
/BODY>


I get this from http://www.bloke.com/javascript/Random/ ,you can visit that for more information.

11/06/2009

How to Play Background sound in your web page





If you wish to play a background sound automatically when display the web page you can use the following html code for that

<
embed src="musicfile.filetype" autostart="true" loop="true" width="2" height="0" >
<
/embed>


In the above code you can use either loop true or false.If use loop equals true then the sound file play repeatedly to the closing of web page.If use loop equals false the sound file play exactly one time.

You can also use the following code.

<
HEAD>
<
bgsound src="music/song.mp3" loop="-1">
<
/HEAD>

You can give the value to the loop.Loop equals -1 means the sound repeatedly play until close the page and also you can give number for the loop for represent the exact times you want to play the sound.