Loading Random pages using javascript


I have 25 different pages named as 1.htm to 25.htm sequentially. I want to load any one of the page from the 25 pages randomly, What kind of code should I use?

Here is the solution for Loading Random Pages using Javascript:

<html>


<head>

<script language="JavaScript">

function gotoo(url)


{


window.location=url;

document.getElementById("myframe").src=url;


}



function RandLink()


{


var a; a = 1+Math.round(Math.random()*25);


var str;

if (a >=1 && a<= 25)

str = "http://tamilnenjam.googlepages.com/"
+ a + ".htm";

else

str = "http://tamilnenjam.googlepages.com/"
+ "1" + ".htm";

gotoo(str);


}

</script>


</head>




<body onload="RandLink();return false;">



<iframe id="myframe" src=""


scrolling="no" marginwidth="0"


marginheight="0" frameborder="0"


vspace="0" hspace="0" >

</iframe>


</html>

For Testing Purpose, I uploaded 25 different .htm pages in google pages site.
The above code will load Random pages using Javascript.

Enjoy Coding.

You can download the sample code directly from here:

http://tamilnenjam.googlepages.com/whatnext.htm [ Right Click --> and Save As ]

No comments: