Вопрос по js баг к эксплорером.

chemax
На сайте с 07.01.2009
Offline
206
486

есть 2 слоя. один closemon другой top_content

и функция

   

function monClose(){
document.getElementById('closemon').style.display="block";
document.getElementById('closemon').style.left=document.getElementById('top_content').offsetLeft;
document.getElementById('closemon').style.top=document.getElementById('top_content').offsetTop;
document.getElementById('closemon').style.width=document.getElementById('top_content').offsetWidth;
document.getElementById('closemon').style.height=document.getElementById('top_content').offsetheight;
}

функция накладывает closemon поверх top_content

все работает хорошо, но в эксплорере баг

при выравнивании слоя top_content по центру, closemon отображается криво. как решить?

Качественный хостинг, VPS и сервера. (http://ihc.ru/?ref=569)
I
На сайте с 21.02.2008
Offline
117
#1

chemax, в предпоследней строке offsetheight, замените на offsetHeight.

chemax
На сайте с 07.01.2009
Offline
206
#2
ippoman:
chemax, в предпоследней строке offsetheight, замените на offsetHeight.

это высота. она не играет роли. тут с лефт и топ глючат

в локальном скрипте все норм с offsetHeight, сюда переносил закосячил.

A
На сайте с 11.05.2009
Offline
99
#3

document.getElementById('closemon').style.left=document.getElementById('top_content').offsetLeft+'px';

document.getElementById('closemon').style.top=document.getElementById('top_content').offsetTop+'px';
document.getElementById('closemon').style.width=document.getElementById('top_content').offsetWidth+'px';
document.getElementById('closemon').style.height=document.getElementById('top_content').offsetheight+'px';

должно помочь

chemax
На сайте с 07.01.2009
Offline
206
#4

примерно так:

<style>

body{
margin: 0;
text-align:center;}
#a0{
width:300px;}
#wrap{
width:300px;
margin:auto;}
#a1{
border: 4px double black;}
#a2{
background:#000;
position:absolute;
display:none;}
</style>
<script>
function bac(){
if(document.getElementById('a2').offsetHeight=="0"){
document.getElementById('a2').style.display="block";}
else{document.getElementById('a2').style.display="none";}

document.getElementById('a2').style.left=document.getElementById('a1').offsetLeft;
document.getElementById('a2').style.top=document.getElementById('a1').offsetTop;
document.getElementById('a2').style.width=document.getElementById('a1').offsetWidth;
document.getElementById('a2').style.height=document.getElementById('a1').offsetHeight;

}
</script>
<body>
<div id="wrap">
<div id="a0"></br></br></br></br></br></br></br></br></br></br></br></div>
<div id="a1"></br></br></br></br></br></br></br></br></br></br></br></br></br></div>
<a href="#" onclick="bac();">Бац</a>
</div>
<div id="a2"></div>
</body>
A
На сайте с 11.05.2009
Offline
99
#5

В ие надо добавлять 'px' как я и написал, надеюсь поможет

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий