img

"PRATICA 3: Comportamento JavaScript"

PRINCIPIO DI FUNZIONAMENTO: codice JavaScript per cambiare il foglio di style

<!DOCTYPE html> <html lang="it"> <head> <title>TitoloPagina</title> <meta charset="ISO-8859-1"> <link rel="stylesheet" href="style1.css" /> <link rel="stylesheet" href="style2.css" /> <link rel="stylesheet" href="style3.css" /> <script type="text/javascript"> function style1() { document.styleSheets[0].disabled = false; document.styleSheets[1].disabled = true; document.styleSheets[2].disabled = true; } function style2() { document.styleSheets[0].disabled = true; document.styleSheets[1].disabled = false; document.styleSheets[2].disabled = true; } function style3() { document.styleSheets[0].disabled = true; document.styleSheets[1].disabled = true; document.styleSheets[2].disabled = false; } </script> </head> <body onload="style1()"> <br><br><hr> <p id="paragrafo"><br> Contenuto del paragrafo<br><br></p> <hr> <form> <input type="button" value="Inserisci Style1" onclick="style1()"> <input type="button" value="Inserisci Style2" onclick="style2()"> <input type="button" value="Inserisci Style3" onclick="style3()"> </form> </body> </html>

(Browser) PROVARE IL funzionamento con il codice JavaScript