这个JS不兼容火狐浏览器,请高手帮忙(修改版)..

yy4143291 2012-03-12 02:01:32
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>

<style>
#content,#intro{
font: 13px/25px;
width: 200px;
height: 50px;
background: #eee;
padding: 10px;
border: 4px #ccc double;
border-bottom:0;
overflow: hidden;
}
#intro {
color: #036;
font:12px;
border: 4px #ccc double;
border-top:0;
height:70px;
}
#key{color:#900;float:right}
hr{height:1px;border:1px #ccc dotted}
</style>
<script>
var s=3;
var minheight=50;
var maxheight=400;
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>
</head>

<body>


<div id="content">
孤雁儿
<br><br>
世人作梅词,下笔便俗。予试作一篇,乃知前言不妄耳。<br><br>
藤床纸帐朝眠起,<br>
说不尽、无佳思。<br>
沈香烟断玉炉寒,<br>
伴我情怀如水。<br>
笛声三弄,<br>
梅心惊破,<br>
多少春情意。<br><br>
小风疏雨萧萧地,<br>
又催下、千行泪。<br>
吹箫人去玉楼空,<br>
肠断与谁同倚?
一枝折得,<br>
人间天上,<br>
没个人堪寄。
</div>
<div id="intro" ><hr>作者:李清照<span id="key" onclick="shoppingcat();">展开</span><br>来源
:中国诗辞网</div>


</body>
</html>
...全文
203 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
狼窝乀野狼 2012-03-12
  • 打赏
  • 举报
回复
因为firefox是用的与遨游一个内核,不是IE的,所以你需要一个判断:
if(window.XMLHttpRequest){
if(!window.ActiveXObject){
//Mozilla,Safari
alert("Mozilla,FireFox,Safari");
var cssrules = document.styleSheets[0].cssRules }else{
alert("IE");
var cssrules = document.styleSheets[0].rules;//这种形式只支持IE;
}

}else {
alert("IE6");
}
Acesidonu 2012-03-12
  • 打赏
  • 举报
回复

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>

<style>
#content,#intro{
font: 13px/25px;
width: 200px;
height: 50px;
background: #eee;
padding: 10px;
border: 4px #ccc double;
border-bottom:0;
overflow: hidden;
}
#intro {
color: #036;
font:12px;
border: 4px #ccc double;
border-top:0;
height:70px;
}
#key{color:#900;float:right}
hr{height:1px;border:1px #ccc dotted}
</style>
<script>
var s=3;
var minheight=50;
var maxheight=400;
function shoppingcat(){
var key = document.getElementById("key").innerHTML;
var content = document.getElementById("content");
if (isNaN(parseInt(content.style.height)))
content.style.height='0px';
if(key=="展开"){
content.style.height=parseInt(content.style.height)+s+'px';
if(parseInt(content.style.height)<maxheight){
setTimeout("shoppingcat();",1);
}else{
document.getElementById("key").innerHTML="关闭";
}
}else{
content.style.height=parseInt(content.style.height)-s+'px';
if(parseInt(content.style.height)>minheight){
setTimeout("shoppingcat();",1);
}else{
document.getElementById("key").innerHTML="展开";
}
}
}
</script>
</head>

<body>


<div id="content">
孤雁儿
<br><br>
世人作梅词,下笔便俗。予试作一篇,乃知前言不妄耳。<br><br>
藤床纸帐朝眠起,<br>
说不尽、无佳思。<br>
沈香烟断玉炉寒,<br>
伴我情怀如水。<br>
笛声三弄,<br>
梅心惊破,<br>
多少春情意。<br><br>
小风疏雨萧萧地,<br>
又催下、千行泪。<br>
吹箫人去玉楼空,<br>
肠断与谁同倚?
一枝折得,<br>
人间天上,<br>
没个人堪寄。
</div>
<div id="intro" ><hr>作者:李清照<span id="key" onclick="shoppingcat();">展开</span><br>来源
:中国诗辞网</div>


</body>
</html>

yy4143291 2012-03-12
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zsx841021 的回复:]
pixelHeight这个不兼容ff。。改成style.Height试试
[/Quote]
试了,没用的还是..
三石-gary 2012-03-12
  • 打赏
  • 举报
回复
pixelHeight这个不兼容ff。。改成style.Height试试

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧