Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    Problema IE 6

    Salve a tutti. Ho notato una stranissima anomalia nel comportamento di IE 6 durante l'esecuzione di un mio script JavaScript. Mozilla Firefox riesce correttamente nell'esecuzione senza nessun messaggio di errore nella console. Con IE 6 invece, lo script si arresta e viene visualizzato il seguente messaggio: http://img50.imageshack.us/img50/6272/screen3qq7.png
    Allora, ho fatto Visualizza - HTML, ho copiato il codice e l'ho incollato in Notepad++ e ho visto cosa c'è alla riga 40, c'è questo: nick = document.getElementById ("nick");

    L'input text ha ovviamente dichiarato l'id "nick", e infatti Mozilla lo esegue correttamente. La cosa che mi fa imbestialire è: perchè IE 6 fa così? Eppure si tratta di una operazione elementare... vi prego aiutatemi
    Questo è il codice completo (quello statico preso da IE), se può aiutarvi:

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    	<head>
    		<title>Dieffe web - Home</title>
    		<meta http-equiv="content-type" content="text/html;charset=windows-1252">
    		<link rel = "stylesheet" type = "text/css" href = "style.css">
    	</head>
    	<body>
    		<script type = "text/javascript" src = "../jslib.js"></script>
    <script type = "text/javascript">
    	//<!--
    			function showLoginForm()
    		{
    			blackdiv = document.getElementById ("black");
    			blackdiv.style.visibility = "visible";
    			
    			logindiv = document.getElementById ("login");
    			logindiv.style.visibility = "visible";
    		}
    		
    		function hideLoginForm()
    		{
    			blackdiv = document.getElementById ("black");
    			blackdiv.style.visibility = "hidden";
    			
    			logindiv = document.getElementById ("login");
    			logindiv.style.visibility = "hidden";
    			
    			nick = document.getElementById ("nick");
    			password = document.getElementById ("password");
    			loginmessage = document.getElementById ("loginmessage");
    			
    			nick.value = "";
    			password.value = "";
    			loginmessage.innerHTML = "";
    		}
    		
    		function sendLoginForm()
    		{
    			nick = document.getElementById ("nick");
    			password = document.getElementById ("password");
    			loginmessage = document.getElementById ("loginmessage");
    			
    			if (nick.value != "" && password.value != "")
    			{
    				request = createXMLHttpRequest
    				(
    					function()
    					{
    						if (request.readyState == 4 && request.status == 200)
    						{
    							response = request.responseText;
    							if (response == "success")
    								window.location.reload();
    							else
    								loginmessage.innerHTML = response;
    						}
    					}
    				);
    				request.open ("get", "../database/login.php?r=" + Math.random() * 10 + "&nick=" + nick.value + "&pwd=" + password.value + "&lang=it");
    				request.send (null);
    			}
    			else
    				loginmessage.innerHTML = "Empty fields";
    		}
    		
    		function showSignupForm()
    		{
    			blackdiv = document.getElementById ("black");
    			blackdiv.style.visibility = "visible";
    			
    			signupdiv = document.getElementById ("signup");
    			signupdiv.style.visibility = "visible";
    		}
    		
    		function hideSignupForm()
    		{
    			blackdiv = document.getElementById ("black");
    			blackdiv.style.visibility = "hidden";
    			
    			logindiv = document.getElementById ("signup");
    			logindiv.style.visibility = "hidden";
    
    			nickfield = document.getElementById ("nickfield");
    			emailfield = document.getElementById ("emailfield");
    			signupmessage = document.getElementById ("signupmessage");
    			
    			nickfield.value = "";
    			emailfield.value = "";
    			signupmessage.innerHTML = "";
    		}
    		
    		function sendSignupForm()
    		{
    			nickfield = document.getElementById ("nickfield");
    			radio1 = document.getElementById ("radio1");
    			radio2 = document.getElementById ("radio2");
    			emailfield = document.getElementById ("emailfield");
    			signupmessage = document.getElementById ("signupmessage");
    			
    			var pemail;
    			if (radio1.checked)
    				pemail = "y";
    			else if (radio2.checked)
    				pemail = "n";
    			
    			next = true;
    			if (nickfield.value == "")
    			{
    				signupmessage.innerHTML = "Nick field is empty";
    				next = false;
    			}		
    			else if (emailfield.value == "")
    			{
    				signupmessage.innerHTML = "E-mail field is empty";
    				next = false;
    			}
    			
    			if (next)
    			{
    				request = createXMLHttpRequest
    				(
    					function()
    					{
    						if (request.readyState == 4 && request.status == 200)
    						{
    							response = request.responseText;
    							if (response == "success")
    								location.href = "registration.php";
    							else
    								signupmessage.innerHTML = response;
    						}
    					}
    				);
    				request.open ("get", "../database/registration.php?r=" + Math.random() * 10 + "&nick=" + nickfield.value
    				+ "&email=" + emailfield.value + "&pemail=" + pemail + "&lang=it");
    				request.send (null);
    			}
    		}
    		//-->
    </script>
    <div id = "black">
    </div>
    <div id = "maindiv">
    			<div id = "login">
    			<p style = "text-align: right; margin: 3px;"><a href = "#" onClick = "hideLoginForm(); return false;"><img src = "images/x.png" alt = "Close" border = "0"></a></p>
    			<p style = "font-weight: bold; font-size: 15px;">Accedi</p>
    			<div style = "width: 220px; margin: auto;">
    				<table>
    					<tr>
    						<td>Nick:</td><td><input type = "text" id = "nick" maxlength = "20"></td>
    					</tr>
    					<tr>
    						<td>Password:</td><td><input type = "password" id = "password" maxlength = "25"></td>
    					</tr>
    					<tr>
    						<td></td><td><input type = "submit" value = "Accedi" onClick = "sendLoginForm(); return false;"></td>
    					</tr>
    				</table>
    				<div id = "loginmessage" style = "text-align: center; font-size: 10px; color: red;"></div>
    			</div>
    		</div>
    		<div id = "signup">
    			<p style = "text-align: right; margin: 3px;"><a href = "#" onClick = "hideSignupForm(); return false;"><img src = "images/x.png" alt = "Close" border = "0"></a></p>
    			<p style = "font-weight: bold; font-size: 15px;">Registrati</p>
    			<div style = "width: 240px; margin: auto;">
    				<table>
    					<tr>
    						<td>Nick:</td><td><input type = "text" id = "nickfield" maxlength = "20"></td>
    					</tr>
    					<tr>
    						<td>E-mail:</td><td><input type = "text" id = "emailfield" maxlength = "50"></td>
    					</tr>
    					<tr>
    						<td>E-mail privata:</td><td><input type = "radio" id = "radio1" name = "radio"><label for = "radio1">Yes</label><input type = "radio" id = "radio2" name = "radio" checked = "checked"><label for = "radio2">No</label></td>
    					</tr>
    					<tr>
    						<td></td><td><input type = "submit" value = "Registrati" onClick = "sendSignupForm(); return false;"></td>
    					</tr>
    				</table>
    				<div id = "signupmessage" style = "text-align: center; font-size: 10px; color: red;"></div>
    			</div>
    		</div>
    
    		<div style = "width: 600px; float: left; text-align: left; margin: 2px 10px 0px 6px;">
    			<a href = "#" onClick = "showLoginForm(); return false;">Accedi</a> <span style = "font-size: 14px;">|</span> 
    			<a href = "#" onClick = "showSignupForm(); return false;">Registrati</a>
    		</div>
    		<div style = "width: 135px; float: left; text-align: right; margin: 5px 0px 0px 0px;">
    		<a href = "../en"><img src = "images/enflag.png" alt = "english" border = "0"></a>
    		<a href = "../it"><img src = "images/itflag.png" alt = "italiano" border = "0"></a>
    	</div>
    	<p style = "margin-top: 0px;"><img src = "images/dieffeweb.png" alt = "Dieffe web"></p>
    	<div id = "menudiv">		
    		<div id = "menubuttons">
    			<div style = "width: 720px; margin-left: auto; margin-right: auto;"><a href = "index.php">Home</a><a href = "software.php">Software</a><a href = "jitchat.php">J-it Chat</a><a href = "websites.php">Siti web</a><a href = "contact.php">Contatti</a></div>
    		</div>
    		<div style = "clear:both;"></div>
    	</div>
    </div>	
    		<div id = "bodydiv">
    			<div id = "text">
    				<p style = "font-weight: bold; font-size: 15px;">Benvenuto su Dieffe web .com</p>
    				<div>
    				<script type="text/javascript"><!--
    				google_ad_client = "pub-7051746397843508";
    		/* 728x90, creato 01/05/08 */
    				google_ad_slot = "0681514957";
    		google_ad_width = 728;
    		google_ad_height = 90;
    //-->
    				</script>
    				<script type="text/javascript"
    				src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    				</script>
    				</div>
    				<div style = "text-align: center; width: 520px; margin-right: auto; margin-left: auto;">
    					<a href = "jitchat.php"><img src = "images/downloadChat.png" alt = "Download chat" border = "0" style = "float:left;"></a>
    					<a href = "websites.php"><img src = "images/creationSites.png" alt = "Creation Sites" border = "0" style = "float:left; margin-left:6px;"></a>
    					<div style = "clear:both;"></div>
    				</div>
    				<div style = "clear:both;"></div>
    			</div>
    		</div>
    	</body>
    </html>

  2. #2
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Non so esattamente quale sia la tua linea 40, ma qui di sicuro hai usato come nome di variabile una parola riservata

    password = document.getElementById ("password");

    ciao
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

  3. #3
    Scoperto l'arcano mistero: per IE 6 è un errore di sintassi usare getElementById() senza dichiarare prima la variabile utilizzando "var"

  4. #4
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Originariamente inviato da Dreamer89
    Scoperto l'arcano mistero: per IE 6 è un errore di sintassi usare getElementById() senza dichiarare prima la variabile utilizzando "var"
    L'errore e' usare parole riservate... che specificando var hai bypassato chiarendo al javascript che si tratta di una variabile e non un oggetto della pagina.

    Hai provato ad usare un altro nome?

    ciao
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.