Introduzione
In questo esempio mostrerò un esempio di utilizzo combinato di VBScript e JScript.
Questo esempio utilizza l'Oggetto Request e genera un numero casuale.
Il codice dello script è il seguente:
<%
Dim ora, strServerName, strServerSoftware, intSaluto
ora = Time()
strServerName = Request.ServerVariables("SERVER_NAME")
strServerSoftware = Request.ServerVariables("SERVER_SOFTWARE")
'Genera un numero random.
Randomize
intSaluto= int(rnd * 3)
%>
<SCRIPT LANGUAGE="JScript">
<!--
//Chiama la funzione che mostra il messaggio
showMsg()
function showMsg()
{
switch(<%= intSaluto %>)
{
case 0:
msg = "Questo Web Server è <%= strServerName%>
e stà eseguendo <%= strServerSoftware %>"
break
case 1:
msg = "Benvenuto al <%= strServerName%>. L'ora è <%= ora %>"
break
case 2:
msg = "Questo Server stà eseguendo <%= strServerSoftware %>"
break
}
document.write(msg)
}
-->
</SCRIPT>
La pagina ad ogni suo caricamento mostrerà un saluto a caso tra i tre che sono stati definiti.
|