*

Lajme

Video e javës



   Shpejtesia e Google Chrome.


Diskutimet e fundit


*Ndegjoni Live: ayihRadio - OFF AIR


Pages: [1] |   Go Down
  Send this topic  |  Print  
Topic: Random Link  (Read 8969 times)
« on: April 01, 2008, 03:50:06 PM »
be a part of ayihORG community.
daBaki. Offline
Administrator
Hero Member

*****
Posts: 732



Code:
<html>
<body>

<script type="text/javascript">
var r=Math.random();
if (r>0.5)
{
document.write("<a href='http://www.w3schools.com'>Learn Web Development!</a>");
}
else
{
document.write("<a href='http://www.refsnesdata.no'>Visit Refsnes Data!</a>");
}
</script>

</body>
</html>

ky code do te qes njeher, Learn Web Development! ndersa njeher Visit Refsnes Data!

Nese keni linqe me teper ateher modifikimi eshte me posht

Code:
<script type="text/javascript">
var r=Math.floor(Math.random()*5)+1;
document.write(r);
if (r==1)
{
document.write("<a href='http://www.w3schools.com'>Learn Web Development!</a>");
}
if(r==2)
{
document.write("<a href='http://www.refsnesdata.no'>Visit Refsnes Data!</a>");
}
if(r==3)
{
document.write("Linku shkon ketu");
}
if(r==4)
{
document.write("Linku shkon ketu");
}
if(r==5)
{
document.write("Linku shkon ketu");
}
</script>

Math.floor(Math.random()*5)+1; // ktu i prodhojm numrat random prej 0 - 4, dhe me +1 e bejme qe te kemi nga 1 deri ne 5
ndersa Math.random(); // prodhon numra te ndryshem prej 0 - 1.

Kjo ishte e tera sa i perket Random Link.

Logged

I am what I am because of who we all are.
         
macbook //   
 
Tags: Random Link  JavaScript  Script  Java  Programming 
Pages: [1] |   Go Up
  Send this topic  |  Print  
 
Jump to:  

SEKSIONE   Blogu  |  Galeria  |  Tage

Na kontaktoni | Tregoja mikut | Ndihme | Kerko forumet

English Information | FAQ | Ksalco




graphics by MakeItSimple Studios. ©2008, 2009, 2010, 2011 ayih Organization. Some rights reserved.