Come al solito rinviamo il lettore, per ogni approfondimento, al sito dedicato di JavaScript, mentre ci soffermeremo ad illustrare le istruzioni utilizzate per comporre queste pagine.
Cominciamo col descrivere la funzione che consente di aprire il documento in una finestra esterna, nel qual caso lo script è:
|
<HTML> <HEAD> <TITLE>esempio di JavaScript</TITLE> <SCRIPT LANGUAGE='JavaScript'> <!-- function NomeFunzione(){ var nuovaFinestra = window.open ("NomeDocumento.html", "NomeFinestra","copyhistory=YES,menubar=NO,status=YES, resizable=NO,height=100,width=200") } //--> </SCRIPT> </HEAD> <BODY> <P ALIGN=CENTER> corpo<BR> del<BR> <A HREF="JavaScript:NomeFunzione()"> documento</A> </BODY> </HTML> |
|
<HTML> <HEAD> <TITLE>esempio di menu</TITLE> <SCRIPT LANGUAGE='JavaScript'> <!-- function MakeArray() { var lngth = MakeArray.arguments.length; for ( i = 0 ; i<lngth ; i++ ) { this[i]=MakeArray.arguments[i] } } function prima() { var select = eval(document.menuform.elements[0].selectedIndex); if( (select >0) && (select<4) ) { var intl=new MakeArray( '','documentoA.html','documentoB.html','documentoC.html'); var nuove=intl[document.menuform.elements[0].selectedIndex]; window.open(nuove,"documenti","Toolbar=no,status=no,scrollbars=yes,resizable=yes,menubar=yes,height=100,width=200"); } } function seconda() { var select = eval(document.menuform.elements[1].selectedIndex); if( (select >0) && (select<5) ) { var intl=new MakeArray( '','documento1.html','documento2.html','documento3.html','documento4.html'); var nuove=intl[document.menuform.elements[1].selectedIndex]; window.open(nuove,"documenti","Toolbar=no,status=no,scrollbars=yes,resizable=yes,menubar=yes,height=150,width=150"); } //--> </SCRIPT> </HEAD> <BODY> <P ALIGN=CENTER> <B> Esempio di menu a discesa: </B> <FORM NAME="menuform"> <SELECT NAME="primoMenu" onChange='prima();' > <option selected> PRIMO MENU <option> documento A <option> documento B <option> documento C </select> <SELECT NAME="secondoMenu" onChange='seconda();'> <option selected> SECONDO MENU <option> - documento 1 <option> - documento 2 <option> - documento 3 <option> - documento 4 </SELECT> </form> </BODY> </HTML> |