Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Sök i support

Akta dig för supportbedrägerier: Vi kommer aldrig att be dig att ringa eller skicka ett sms till ett telefonnummer eller dela personlig information. Rapportera misstänkt aktivitet med alternativet "Rapportera missbruk".

Läs mer

Javascript not working in Firefox,chrome,opera but works in IE

  • 2 svar
  • 21 har detta problem
  • 6 visningar
  • Senaste svar av cor-el

more options

This or any other program shows nothing on screen.


<!DOCTYPE html>
<html>
<head>
	<title> Epic! </title>
</head>
<body>
<script type="text/javascript">

var name = new Array("jon","cody","molly");
name.sort();
for (j=0;j<name.length;j++){
document.write(name[j] + "<br>");
}


</script>
</body>
</html>

................................................................................................................................
this say 
,,Undefined

<!DOCTYPE html>
<html>
<head>
	<title> Epic! </title>
</head>
<body>
<script type="text/javascript">

var name = new Array(3);
for (j=0;j<3;j++){
name[j] = prompt ("enter 3 names " ,"");
}
document.write(name[0] + name[1] + name[2]);



</script>
</body>
</html>
This or any other program shows nothing on screen. <pre><nowiki><!DOCTYPE html> <html> <head> <title> Epic! </title> </head> <body> <script type="text/javascript"> var name = new Array("jon","cody","molly"); name.sort(); for (j=0;j<name.length;j++){ document.write(name[j] + "<br>"); } </script> </body> </html> ................................................................................................................................ this say ,,Undefined <!DOCTYPE html> <html> <head> <title> Epic! </title> </head> <body> <script type="text/javascript"> var name = new Array(3); for (j=0;j<3;j++){ name[j] = prompt ("enter 3 names " ,""); } document.write(name[0] + name[1] + name[2]); </script> </body> </html></nowiki></pre>

Ändrad av cor-el

Alla svar (2)

more options

hi Jon92, support.mozilla.org is intended for end-user support. if you have a question regarding web development please refer to Where to go for developer support instead. thank you for your understanding!

more options

That is because "name" is a reserved variable name and can't be used. Just choose something else for the variable name and it will work ('Name' works, may fail in a future Firefox version). You should always be cautious when you choose a common name as the name of a variable as such a name may become reserved.


Web Console: TypeError: name.sort is not a function

Ändrad av cor-el