Предыдущая тема :: Следующая тема |
Автор |
Сообщение |
Kotofeich
Зарегистрирован: 28.12.2006 Сообщения: 2 Откуда: Уфа
|
Добавлено: Чт Дек 28 2006 10:48 Заголовок сообщения: Проблема с javascript |
|
|
На dweb.ru есть статья по dhtml "движение слоя"
http://dweb.ru/articles/index.php?idart=65
Я набрал ее код, а он выдает ошибку. Не могу понять в чем ошибка?
Цитата: |
<body onload="init();moveLayerDown('logo',20,500);">
<script>
var layerRef="null", styleSwitch="null";
function init(){
if (navigator.appName == "Netscape") {
layerRef="document.layers";
styleSwitch="";
}else{
layerRef="document.all";
styleSwitch=".style";
}
}
function moveLayerDown(layerName,currTop,topstop)
{
if (eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.top != topstop'))
{
currTop+=2;
eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.top = currTop');
setTimeout('moveLayerDown("'+layerName+'",'+currTop+','+topstop+')',100);
}
}
}
</script>
<style>
#logo {POSITION: absolute; TOP:50; LEFT:150; VISIBILITY: visible; Z-INDEX: 84000;
WIDTH: 360px; HEIGHT: 280px;}
</style>
<div>
Здарова народ!
</div>
</body>
|
|
|
Вернуться к началу |
|
|
marmazetka
Зарегистрирован: 28.12.2006 Сообщения: 5
|
Добавлено: Чт Дек 28 2006 16:03 Заголовок сообщения: |
|
|
<script>
function moveLayerDown(layerName,currTop,topstop)
{
//alert(layerName+', '+currTop+', '+topstop);
if (document.getElementById(layerName).style.top != topstop)
{
currTop+=2;
document.getElementById(layerName).style.top = currTop;
setTimeout('moveLayerDown("'+layerName+'",'+currTop+','+topstop+')',10);
}
}
</script>
<body text=white>
<table height='500' width='100%' bgcolor=blue onmousemove="moveLayerDown('logo',20,500);"><td><tr>
</td></tr>
<div id='logo' style='POSITION: absolute; TOP:50; LEFT:150; display:block; WIDTH: 360px; HEIGHT: 280px;'>
Здарова народ!
</div>
</body> |
|
Вернуться к началу |
|
|
marmazetka
Зарегистрирован: 28.12.2006 Сообщения: 5
|
Добавлено: Чт Дек 28 2006 17:02 Заголовок сообщения: |
|
|
вот тут совсем правильно
<script type="text/javascript">
function moveLayerDown(layerName,currTop,topstop)
{
if (document.getElementById(layerName).style.top != topstop+'px')
{currTop+=2;
document.getElementById(layerName).style.top = currTop;
setTimeout('moveLayerDown("'+layerName+'",'+currTop+','+topstop+')',10);
}}
</script>
<body>
<div id='logo' style='POSITION:absolute; TOP:50; LEFT:150; display:block; WIDTH: 360px; HEIGHT: 280px;'>
Здарова народ!
</div>
<script type="text/javascript">
moveLayerDown('logo',20,500);
</script>
</body> |
|
Вернуться к началу |
|
|
|