如何使下面的代码在IE6和火狐下支持 请提供方案 这是一段~~ 展开~~~收起~DIV层的代码,IE6和火狐不支持
<script>vars=50;varminheight=100;varmaxheight=350;functionshoppingcat(){varkey=docume...
<script>
var s=50;
var minheight=100;
var maxheight=350;
function shoppingcat(){
var key = document.getElementById("key").innerText;
if(key=="展开"){
content.style.pixelHeight+=s;
if(content.style.pixelHeight<maxheight){
setTimeout("shoppingcat();",1);
}else{
document.getElementById("key").innerText="收起";
}
}else{
content.style.pixelHeight-=s;
if(content.style.pixelHeight>minheight){
setTimeout("shoppingcat();",1);
}else{
document.getElementById("key").innerText="展开";
}
}
}
</script>
<div id="content" style="height:350px; width:900px; margin:0px auto;"><div style="height:400px; width:900px;background-image:url(/images/topbg.jpg); ">
<!-- top-->
</div>
</div>
<div id="intro" style="margin:0 auto;text-align:right; width:900px; height:12px; line-height:12px; color:#8c7d67;cursor:pointer;" ><img src="/Images/iocss.gif" width="12" height="12" /><span id="key" onClick="shoppingcat();">收起</span></div> 展开
var s=50;
var minheight=100;
var maxheight=350;
function shoppingcat(){
var key = document.getElementById("key").innerText;
if(key=="展开"){
content.style.pixelHeight+=s;
if(content.style.pixelHeight<maxheight){
setTimeout("shoppingcat();",1);
}else{
document.getElementById("key").innerText="收起";
}
}else{
content.style.pixelHeight-=s;
if(content.style.pixelHeight>minheight){
setTimeout("shoppingcat();",1);
}else{
document.getElementById("key").innerText="展开";
}
}
}
</script>
<div id="content" style="height:350px; width:900px; margin:0px auto;"><div style="height:400px; width:900px;background-image:url(/images/topbg.jpg); ">
<!-- top-->
</div>
</div>
<div id="intro" style="margin:0 auto;text-align:right; width:900px; height:12px; line-height:12px; color:#8c7d67;cursor:pointer;" ><img src="/Images/iocss.gif" width="12" height="12" /><span id="key" onClick="shoppingcat();">收起</span></div> 展开
4个回答
展开全部
您好,感谢您对火狐的支持
修改下就可以了:
script language="javascript">
var h = 28;var tf = false;var st = false;var key = document.getElementById("key");var content = document.getElementById("content");
function show_hide(){ if (tf) { key.innerHTML = "展开"; } else { key.innerHTML = "关闭"; } clearTimeout(st); st = setTimeout("fn()",20); tf = !tf;
您可以在火狐官方网站下载火狐浏览器,在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。
修改下就可以了:
script language="javascript">
var h = 28;var tf = false;var st = false;var key = document.getElementById("key");var content = document.getElementById("content");
function show_hide(){ if (tf) { key.innerHTML = "展开"; } else { key.innerHTML = "关闭"; } clearTimeout(st); st = setTimeout("fn()",20); tf = !tf;
您可以在火狐官方网站下载火狐浏览器,在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。
展开全部
给你写了个简单的.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<!-- 引入jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$('.open').click(function(){
$('.con').toggleClass("selected");
})
})
</script>
</head>
<body>
<style>
.selected{display:none;}
</style>
<div class="open">展开/收缩</div>
<div class="con">我是内容我是内容</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<!-- 引入jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$('.open').click(function(){
$('.con').toggleClass("selected");
})
})
</script>
</head>
<body>
<style>
.selected{display:none;}
</style>
<div class="open">展开/收缩</div>
<div class="con">我是内容我是内容</div>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<script language="javascript">
var h = 28;var tf = false;var st = false;var key = document.getElementById("key");var content = document.getElementById("content");
function show_hide(){ if (tf) { key.innerHTML = "展开"; } else { key.innerHTML = "关闭"; } clearTimeout(st); st = setTimeout("fn()",20); tf = !tf;
}function fn(){ if (h<28 || h>300) { clearTimeout(st); if (h<28) { h = 28; } else if (h>300) { h = 300; } } else { content.style.height = h + "px"; if (tf) { h += 5; } else { h -=5; } } st = setTimeout("fn()",20);
}
</script>
var h = 28;var tf = false;var st = false;var key = document.getElementById("key");var content = document.getElementById("content");
function show_hide(){ if (tf) { key.innerHTML = "展开"; } else { key.innerHTML = "关闭"; } clearTimeout(st); st = setTimeout("fn()",20); tf = !tf;
}function fn(){ if (h<28 || h>300) { clearTimeout(st); if (h<28) { h = 28; } else if (h>300) { h = 300; } } else { content.style.height = h + "px"; if (tf) { h += 5; } else { h -=5; } } st = setTimeout("fn()",20);
}
</script>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
加上"px"试试,content.style.pixelHeight=(content.style.pixelHeight+s)+"px";
更多追问追答
追问
请问能详细点么?加哪?
追答
汗。。。那不是都写出来了吗,看来这个代码不是你写的?感觉你的代码有点乱啊,不支持IE6是因为IE6如果超出HEIGHT会自动扩充DIV ,不支持FF等非IE浏览器是因为你的content没有获取对象,没有加高度单位。。如果不行的话你根据这两点把代码修改一下吧
var s=50;
var minheight=100;
var maxheight=350;
function shoppingcat(){
var content=document.getElementById("content");
var key = document.getElementById("key").innerText;
if(key=="展开"){
content.style.pixelHeight=(content.style.pixelHeight+s)+"px";
if(content.style.pixelHeightminheight){
setTimeout("shoppingcat();",1);
}else{
document.getElementById("key").innerText="展开";
}
}
}
收起
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询