Files
unisa_tsw_2014_2015/js_9.html
2014-11-30 18:46:24 +01:00

62 lines
1.4 KiB
HTML

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script>
input = prompt ("Colore titolo, testo, sfondo e grandezza font");
var res = input.split(" ");
if (res[0] == "*")
document.writeln("<link rel=\"stylesheet\" type=\"text/css\" href=\"mystyle.css\">");
else {
document.writeln("<style>");
if (res[0]==res[1] || res[0]==res[2] || res[1]==res[2] ){
res[0]="green";
res[1]="blue";
res[2]="red";
}
document.writeln("h1,h2,h3,h4,h5,h6 {color:" + res[0] + ";font-size:" + res[3] + "}");
document.writeln("body {background-color:" + res[2] + "}");
document.writeln("p {color:" + res[1] + "}");
document.writeln("</style>");
}
</script>
</head>
<body>
<h1> Titolo 1</h1>
<h2> Titolo 2</h2>
<h3> Titolo 3</h3>
<p>Ehi</p>
<script>
h1s = document.getElementsByTagName("h1");
for (i = 0 ;i<h1s.length; i++)
h1s[i].style="font-size:3em;font-weight:bold";
h2s = document.getElementsByTagName("h2");
for (i = 0 ;i<h2s.length; i++)
h2s[i].style="font-size:1em";
h3s = document.getElementsByTagName("h3");
for (i = 0 ;i<h3s.length; i++)
h3s[i].style="font-size:1em;font-weight:bold;font-style=italic";
</script>
</body>
</html>