Homepage  Il progetto dsy.it è l'unofficial support site dei corsi di laurea del Dipartimento di Scienze dell'Informazione e del Dipartimento di Informatica e Comunicazione della Statale di Milano. E' un servizio degli studenti per gli studenti, curato in modo no-profit da un gruppo di essi. I nostri servizi comprendono aree di discussione per ogni Corso di Laurea, un'area download per lo scambio file, una raccolta di link e un motore di ricerca, il supporto agli studenti lavoratori, il forum hosting per Professori e studenti, i blog, e molto altro...
In questa sezione è indicizzato in textonly il contenuto del nostro forum


.dsy:it. .dsy:it. Archive > Community > Tech
 
[HTML+javascript] perchè da mozilla non funziona?
Clicca QUI per vedere il messaggio nel forum
0m4r
come da oggetto, questo è il codice:
code:
<!DOCTYPE HTML SYSTEM "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>test</title> <Link rel="stylesheet" type="text/css" href="bannerDefault.css"/> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> <script type="text/javascript"> function paint(){ var r = document.cp.red.value; var g = document.cp.green.value; var b = document.cp.blue.value; var bw = document.cp.colorbox; var rok = true; var gok = true; var bok = true; if(0>r || r>255){ alert("RED has an INVALID value: it need to be between 0 and 255"); rok = false; } if(0>g || g>255){ alert("GREEN has an INVALID value: it need to be between 0 and 255"); gok = false; } if(0>b || b>255){ alert("BLUE has an INVALID value: it need to be between 0 and 255"); bok = false; } if(rok && gok && bok){ document.getElementById("colorbox").style.backgroundColor='rgb('+r+','+g+','+b+')'; } } function resize(){ var h = document.cp.thumbHeight.value; var w = document.cp.thumbWidth.value; var hok = true; var wok = true; if(h<50 || h>300){ alert("HEIGHT has an INVALID value: it need to be between 50 and 300"); hok = false; } if(w<50 || w>300){ alert("WIDTH has an INVALID value: it need to be between 50 and 300"); wok = false; } if(wok){ document.getElementById("colorbox").style.width=w; alert(document.getElementById("colorbox").style.width); document.getElementById("colorbox").style.width=w; } if(hok){ document.getElementById("colorbox").style.height=h+''; } } </script> </head> <body onload="paint(), resize()"> <form method="post" action="test.html" name="cp"> <table class="gallery"> <tr> <td colspan="2" style="font-weight:bold;"> Dimensioni Icone </td> </tr> <td style="width:50%; text-align:right; border:0px solid blue"> Width : </td> <td style="width:50%; text-align:left; border:0px solid blue"> <input name="thumbWidth" value="250" style="border:1px solid gray" maxlength="3" size="3" onChange="resize()"> px </td> </tr> <tr> <td style="width:50%; text-align:right; border:0px solid blue"> Height : </td> <td style="width:50%; text-align:left; border:0px solid blue"> <input name="thumbHeight" value="150" style="border:1px solid gray" maxlength="3" size="3" onChange="resize()"> px </td> </tr> <tr> <td colspan="2">   </td> </tr> <tr> <td colspan="2" style="font-weight:bold;"> Background </td> </tr> <tr> <td style="width:50%; text-align:right; border:0px solid blue"> Red : </td> <td style="width:50%; text-align:left; border:0px solid blue"> <input name="red" value="255" style="border:1px solid gray; color:red" maxlength="3" size="3" OnKeyUp="paint()"> px </td> </tr> <tr> <td style="width:50%; text-align:right; border:0px solid blue"> Green : </td> <td style="width:50%; text-align:left; border:0px solid blue"> <input name="green" value="200" style="border:1px solid gray; color:green" maxlength="3" size="3" OnKeyUp="paint()"> px </td> </tr> <tr> <td style="width:50%; text-align:right; border:0px solid blue"> Blue : </td> <td style="width:50%; text-align:left; border:0px solid blue"> <input name="blue" value="180" style="border:1px solid gray; color:blue" maxlength="3" size="3" OnKeyUp="paint()"> px </td> </tr> <tr> <td colspan="2" style="font-weight:bold;">   </td> </tr> <tr> <td colspan="2" style="font-weight:bold;"> Preview </td> </tr> <tr> <td colspan="2" align="center"> <div id="colorbox" style="border:1px solid red;">   </div> </td> </tr> </table> </form> </body> </html>

yeah
1) Quando, in resize(), cambi le dimensioni, oltre al valore della variabile aggiungi "px" (es [...].width = w + "px"; )
2) Nello stile del colorbox aggiungi i parametri che cambi nel codice java script: width, height e backgroundColor e assegna valori di default

Dimmi se va :)

0m4r
Originally posted by yeah
1) Quando, in resize(), cambi le dimensioni, oltre al valore della variabile aggiungi "px" (es [...].width = w + "px"; )


FANTASTICO, funziona. Anche se mi sembra un'assurdità non vederlo funzionare semplicemente per l'unità di misura. Comunque ora va!

Originally posted by yeah
2) Nello stile del colorbox aggiungi i parametri che cambi nel codice java script: width, height e backgroundColor e assegna valori di default

La funziona che mi colora il <div> funzionava anche prima, quindi problema risolto gia in partenza!


Originally posted by yeah
Dimmi se va :)

Va!

yeah
Perfetto :)

Powered by: vbHome (lite) v4.1 and vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento |Licenze | Thanks | Syndacate