Javascript-форум (https://javascript.ru/forum/)
-   Opera, Safari и др. (https://javascript.ru/forum/css-html-browser/)
-   -   top is not a function (https://javascript.ru/forum/css-html-browser/24882-top-not-function.html)

function 17.01.2012 22:02

top is not a function
 
Есть код:
<html>


<head>

<title>css-игра</title>

<script>

var t;
var l;

 function top()
{t=document.im.style;
 t.top = parseInt(t.top) + 1 + 'px';
 setTimeout("top();",50);}
 
  function left()
{l=document.im.style;
 l.left = parseInt(l.left) + 5 + 'px';}
 
  function right()
{l=document.im.style;
 l.left = parseInt(l.left) - 5 + 'px';}
 
  function bottom()
{t=document.im.style;
 t.top = parseInt(t.top) - 5 + 'px';}

</script>

</head>


<body>

<p align="center">

<img name="im" src="http://sait-raznoe.do.am/pr/2/0.png" style="top:0px; left:0px; position : relative;">

<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>

<input type="button" value="&uarr;" onclick=bottom()>

<BR>

<input type="button" value="&larr;" onclick=right()>&nbsp &nbsp &nbsp &nbsp <input type="button" value="&rarr;" onclick=left()>

<BR>

<input type="button" value="&darr;" onclick=top()>

</p>

</body>


</html>


В опере выдаётся ошибка: "top is not a function". Причём в других браузерах всё нормально. Чем опера так отличилась7
P.S. - ошибку исправил изначально, пишу только из любопытства.

Kolyaj 17.01.2012 22:42

top -- зарезервированная переменная.

function 18.01.2012 09:13

А почему именно top? Есть же много переменных наподобие него - right и т.п.


Часовой пояс GMT +3, время: 08:25.