Търсене в помощните статии

Избягвайте измамите при поддръжката. Никога няма да ви помолим да се обадите или изпратите SMS на телефонен номер или да споделите лична информация. Моля, докладвайте подозрителна активност на "Докладване за злоупотреба".

Научете повече

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

  • 2 отговора
  • 21 имат този проблем
  • 6 изгледи
  • Последен отговор от 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>

Променено на от cor-el

Всички отговори (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

Променено на от cor-el