Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

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

  • 2 replies
  • 21 have this problem
  • 6 views
  • Last reply by 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>

Modified by cor-el

All Replies (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

Modified by cor-el