点击指点广告后显示隐藏内容完美代码(支持FF和IE)
作者:shaoyun 日期:2010-01-21
本人前些时间有发表一篇文章介绍如何点击广告后才能查看指定内容(http://www.iloveyiwu.com/article/IT/点击广告后才可以查看指定内容.htm),那个代码看着也挺简单实用,但经本人测试在IE6下运行正常,但在FF3下无论怎么点广告总是不显示指点内容,看来这个代码不完美,而对追求完美的我来说是无法认识的,网上查了多个类似代码,最后在蓝色理想发现一个朋友比较完美支持IE6和FF3的代码,下面分享该代码,对代码作者浩波表示感谢(出处http://bbs.blueidea.com/thread-2837431-1-1.html)。事实上这个代码可以用在广告点击,也可以用在显示和隐藏二级菜单等,远离都相同的,看大家灵活运用了
<style type="text/css">
<!--
#i001 {
display:none;
}
-->
</style>
<script type="text/javascript">
function show(obj) {
var showObj=document.getElementById(obj);
showObj.style.display=(GetCurrentStyle(showObj,"display")=="block")?"none":"block";
}
function GetCurrentStyle (obj, prop) {
if (obj.currentStyle) {
return obj.currentStyle[prop];
}
else if (window.getComputedStyle) {
prop = prop.replace (/([A-Z])/g, "-$1");
prop = prop.toLowerCase ();
return window.getComputedStyle (obj, "").getPropertyValue(prop);
}
return null;
}
</script>
<div id="i01">
<ul>
<li class="hand" onclick="show('i001')">系统管理</li>
</ul>
<ul id="i001">
<li>账号管理</li>
<li>访问记录</li>
</ul>
</div>
<style type="text/css">
<!--
#i001 {
display:none;
}
-->
</style>
<script type="text/javascript">
function show(obj) {
var showObj=document.getElementById(obj);
showObj.style.display=(GetCurrentStyle(showObj,"display")=="block")?"none":"block";
}
function GetCurrentStyle (obj, prop) {
if (obj.currentStyle) {
return obj.currentStyle[prop];
}
else if (window.getComputedStyle) {
prop = prop.replace (/([A-Z])/g, "-$1");
prop = prop.toLowerCase ();
return window.getComputedStyle (obj, "").getPropertyValue(prop);
}
return null;
}
</script>
<div id="i01">
<ul>
<li class="hand" onclick="show('i001')">系统管理</li>
</ul>
<ul id="i001">
<li>账号管理</li>
<li>访问记录</li>
</ul>
</div>
评论: 0 | 引用: 0 | 查看次数: -
发表评论
上一篇
下一篇

文章来自:
Tags:
相关日志: