Jump to content
  • 0

slide


chus
 Share

Question

Сижу уже три часа в ИЕ отказываеться работать =(

А точнее не понимает вот эту строчку var h = document.getElementById(obj).clientHeight-5;

<html>
<head>
<script type="text/javascript">
var idinterval;
var saveH;
var obj;
var t = 0;
function sh(v){
if(t == 0){
saveH = document.getElementById(v).clientHeight;
obj = v;
idinterval = setInterval("h()", 10);
t = 1;
}else if(t == 1){
obj = v;
idinterval = setInterval("s()", 10);
t = 0;
}
}
function h(){
var h = document.getElementById(obj).clientHeight-5;
document.getElementById(obj).style.height = h+'px'
if(h < 0){
document.getElementById(obj).style.display = 'none';
clearInterval(idinterval);
}
}
function s(){
document.getElementById(obj).style.display = 'block';
var h = document.getElementById(obj).clientHeight+5;
document.getElementById(obj).style.height = h+'px'
if(h == saveH){
clearInterval(idinterval);
}
}
</script>
</head>
<body>
<div id="demo">
<a id="slideout" href="java script: sh('test')">slideout</a>
<div id="test" style="overflow:hidden; border: solid 1px #000; background: #fcfcfc;"> text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
</div>
</div>
</body>
</html>

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Огромное спасибо за помощь. Оказалось в ИЕ что бы обект возврошал не 0 от свойства clientHeight он должен получить layout. Теперь рабоотает во все браузерах но в ИЕ после каждого открытия пропадает пиксель не могу догнать почему =)

<html>
<head>
<script type="text/javascript">
var idinterval;
var height = 0;
var heightS = 0;
var flag = 1;
function clickDiv(v){
if(flag == 1){
flag = 2;
height = document.getElementById(v).clientHeight;
heightS = document.getElementById(v).clientHeight;
idinterval = setInterval("hideDiv('"+v+"')", 10);
}else if(flag == 0){
flag =2;
height = 0;
idinterval = setInterval("showDiv('"+v+"')",10);
}
}

function hideDiv(obj){
height = height-15;
if(height <= 0){
document.getElementById(obj).style.height = 0;
document.getElementById(obj).style.display = 'none';
clearInterval(idinterval);
flag = 0;
}else{
document.getElementById(obj).style.height = height;
}
}

function showDiv(obj){
if(height == 0){
document.getElementById(obj).style.display = 'block';
}
height = height+15;
if(height > heightS){
document.getElementById(obj).style.height = heightS;
clearInterval(idinterval);
flag = 1;
}else{
document.getElementById(obj).style.height = height;
}

}

</script>
</head>
<body>
<div id="demo">
<a id="slideout" href="java script: clickDiv('test')">slideout</a>

<div id="test" style="overflow:hidden; border: solid 1px #000; background: #fcfcfc; display:inline-block; width: 100%">
<h2>Заголовок</h2>
<p>1 text text text text text text text text text text text text text text text text text text te</p>
<p>2 text text text text text text text text text text text text text text text text text text text text </p>
<p>3 text text text text text text text text text text text text text text text </p>
<p>4 text text text text text text text text text text text text text text </p>
<p>5 text text text text text text text text text text text text text text text text </p>
<p>6 text text text text text text text text text text text text text text text text text text </p>
<p>7 text text text text text text text text text text text text text text text text </p>
<p>8 text text text text text text text text text text text text text </p>
<p>9 text text text text text text text text text text text text text text text </p>
<p>10 text text text text text text text text text text text text text text text text </p>
</div>
</div>
</body>
</html>

Link to comment
Share on other sites

  • 0

Ура эврика =)

<html>
<head>
<script type="text/javascript">
var idinterval;
var height = 0;
var heightS = 0;
var flag = 1;
function clickDiv(v){
if(flag == 1){
flag = 2;
height = document.getElementById(v).clientHeight;
heightS = height
idinterval = setInterval("hideDiv('"+v+"')", 10);
}else if(flag == 0){
flag =2;
height = 0;
idinterval = setInterval("showDiv('"+v+"')",10);
}
}

function hideDiv(obj){
height = height-15;
if(height <= 0){
document.getElementById(obj).style.height = 0;
document.getElementById(obj).style.display = 'none';
clearInterval(idinterval);
flag = 0;
}else{
document.getElementById(obj).style.height = height;
}
}

function showDiv(obj){
if(height == 0){
document.getElementById(obj).style.display = 'block';
}
height = height+15;
if(height > heightS){
document.getElementById(obj).style.height = 'auto';
clearInterval(idinterval);
flag = 1;
}else{
document.getElementById(obj).style.height = height;
}

}

</script>
</head>
<body>
<div id="demo">
<a id="slideout" href="java script: clickDiv('test')">slideout</a>

<div id="test" style="overflow:hidden; border: solid 1px #000; background: #fcfcfc; display:inline-block; width: 100%">
<h2>Заголовок</h2>
<p>1 text text text text text text text text text text text text text text text text text text te</p>
<p>2 text text text text text text text text text text text text text text text text text text text text </p>
<p>3 text text text text text text text text text text text text text text text </p>
<p>4 text text text text text text text text text text text text text text </p>
<p>5 text text text text text text text text text text text text text text text text </p>
<p>6 text text text text text text text text text text text text text text text text text text </p>
<p>7 text text text text text text text text text text text text text text text text </p>
<p>8 text text text text text text text text text text text text text </p>
<p>9 text text text text text text text text text text text text text text text </p>
<p>10 text text text text text text text text text text text text text text text text </p>
</div>
</div>
</body>
</html>

Всем спасибо вопрос решен. Отдельное спасибо , , , ,.

Если кто то сможет оптимизировать буду очень признателен =)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy