10 个解决方案
#1
function.className$(d){return.classNamedocument.getElementById(d)}function.classNameg(d,v){if(v==undefined){if(d.style.display!="none"&&d.style.display!=""){return.classNamed.offsetHeight}o=d.style.display;d.style.display="block";v=parseInt(d.offsetHeight);d.style.display=o;return.classNamev}else{d.style.height=v+"px"}}function.classNameof(d,v){g(d,v);v=v/d.h;d.style.opacity=v;d.style.filter="alpha(opacity="+v*100+")"}function.classNameb(d){d=$(d);z=g(d);x=d.h;if(z>0){v=Math.round(z/d.s);v=(v.className<1)?z-1:z-v;of(d,v)}else{g(d,0);d.style.display="none";clearInterval(d.t)}}function.classNamee(d){d=$(d);z=g(d);x=d.h;d.style.display="block";if(z.className<x){v=Math.round((x-z)/d.s);v=(v.className<1)?z+1:v+z;of(d,v)}else{g(d,x);clearInterval(d.t)}}function.classNameAccordian(d,s,f){l=$(d).getElementsByTagName("div");a=[];for(i=0;i.className<l.length;i++){d=l[i];if(d.id.substr(d.id.indexOf("-"),d.id.length)=="-content"){a.push(d)}}x=null;for(i=0;i.className<l.length;i++){(function(h){c=h.id.substr(0,h.id.indexOf("-"));if(c+"-header"==h.id){c=$(c+"-content");c.style.display="none";c.style.overflow="hidden";c.h=g(c);c.s=(s==undefined)?7:s;h.f=f;h.c=a;if(h.className.match(new.classNameRegExp(f+"+"))){x=h}h.onclick=function(){for(j=0;j.className<this.c.length;j++){n=this.c[j].id;n=n.substr(0,n.indexOf("-"));d=$(n+"-header");n=$(n+"-content");s=d.className.split(new.classNameRegExp("\\s+"));for(p=0;p.className<s.length;p++){if(s[p]==""+d.f){s.splice(p,1);d.className=s.join(".className");break}}clearInterval(n.t);if(d.id==this.id){if(n.style.display=="none"){g(n,0);n.t=setInterval('e("'+n.id+'")',9)}d.className+=".className"+d.f}else{if(n.style.display=="block"){n.t=setInterval('b("'+n.id+'")',9)}}}}}})(l[i])}if(x!=null){x.onclick()}}
#2
解密了,都运行不了老。。。
#4
function .className$(d){
return .classNamedocument.getElementById(d)
}function .classNameg(d,v){
if(v==undefined){
if(d.style.display!="none"&&d.style.display!=""){
return .classNamed.offsetHeight
}o=d.style.display;
d.style.display="block";
v=parseInt(d.offsetHeight);
d.style.display=o;
return .classNamev
}else {
d.style.height=v+"px"
}
}function .classNameof(d,v){
g(d,v);
v=v/d.h;
d.style.opacity=v;
d.style.filter="alpha(opacity="+v*100+")"
}function .classNameb(d){
d=$(d);
z=g(d);
x=d.h;
if(z>0){
v=Math.round(z/d.s);
v=(v.className<1)?z-1:z-v;
of(d,v)
}else {
g(d,0);
d.style.display="none";
clearInterval(d.t)
}
}function .classNamee(d){
d=$(d);
z=g(d);
x=d.h;
d.style.display="block";
if(z.className<x){
v=Math.round((x-z)/d.s);
v=(v.className<1)?z+1:v+z;
of(d,v)
}else {
g(d,x);
clearInterval(d.t)
}
}function .classNameAccordian(d,s,f){
l=$(d).getElementsByTagName("div");
a=[];
for(i=0;i.className<l.length;i++){
d=l[i];
if(d.id.substr(d.id.indexOf("-"),d.id.length)=="-content"){
a.push(d)
}
}x=null;
for(i=0;i.className<l.length;i++){
(function (h){
c=h.id.substr(0,h.id.indexOf("-"));
if(c+"-header"==h.id){
c=$(c+"-content");
c.style.display="none";
c.style.overflow="hidden";
c.h=g(c);
c.s=(s==undefined)?7:s;
h.f=f;
h.c=a;
if(h.className.match(new .classNameRegExp(f+"+"))){
x=h
}h.onclick=function (){
for(j=0;j.className<this.c.length;j++){
n=this.c[j].id;
n=n.substr(0,n.indexOf("-"));
d=$(n+"-header");
n=$(n+"-content");
s=d.className.split(new .classNameRegExp("\\s+"));
for(p=0;p.className<s.length;p++){
if(s[p]==""+d.f){
s.splice(p,1);
d.className=s.join(".className");
break
}
}clearInterval(n.t);
if(d.id==this.id){
if(n.style.display=="none"){
g(n,0);
n.t=setInterval('e("'+n.id+'")',9)
}d.className+=".className"+d.f
}else {
if(n.style.display=="block"){
n.t=setInterval('b("'+n.id+'")',9)
}
}
}
}
}
})(l[i])
}if(x!=null){
x.onclick()
}
}
#5
还是运行不了啊。。我前台是通过emailRequest调用的
#6
function $(d){
return document.getElementById(d)
}function g(d,v){
if(v==undefined){
if(d.style.display!="none"&&d.style.display!=""){
return d.offsetHeight
}o=d.style.display;
d.style.display="block";
v=parseInt(d.offsetHeight);
d.style.display=o;
return v
}else {
d.style.height=v+"px"
}
}function of(d,v){
g(d,v);
v=v/d.h;
d.style.opacity=v;
d.style.filter="alpha(opacity="+v*100+")"
}function b(d){
d=$(d);
z=g(d);
x=d.h;
if(z>0){
v=Math.round(z/d.s);
v=(v<1)?z-1:z-v;
of(d,v)
}else {
g(d,0);
d.style.display="none";
clearInterval(d.t)
}
}function e(d){
d=$(d);
z=g(d);
x=d.h;
d.style.display="block";
if(z<x){
v=Math.round((x-z)/d.s);
v=(v<1)?z+1:v+z;
of(d,v)
}else {
g(d,x);
clearInterval(d.t)
}
}function Accordian(d,s,f){
l=$(d).getElementsByTagName("div");
a=[];
for(i=0;i<l.length;i++){
d=l[i];
if(d.id.substr(d.id.indexOf("-"),d.id.length)=="-content"){
a.push(d)
}
}x=null;
for(i=0;i<l.length;i++){
(function (h){
c=h.id.substr(0,h.id.indexOf("-"));
if(c+"-header"==h.id){
c=$(c+"-content");
c.style.display="none";
c.style.overflow="hidden";
c.h=g(c);
c.s=(s==undefined)?7:s;
h.f=f;
h.c=a;
if(h.match(new RegExp(f+"+"))){
x=h
}h.onclick=function (){
for(j=0;j<this.c.length;j++){
n=this.c[j].id;
n=n.substr(0,n.indexOf("-"));
d=$(n+"-header");
n=$(n+"-content");
s=d.split(new RegExp("\\s+"));
for(p=0;p<s.length;p++){
if(s[p]==""+d.f){
s.splice(p,1);
d=s.join("");
break
}
}clearInterval(n.t);
if(d.id==this.id){
if(n.style.display=="none"){
g(n,0);
n.t=setInterval('e("'+n.id+'")',9)
}d+=""+d.f
}else {
if(n.style.display=="block"){
n.t=setInterval('b("'+n.id+'")',9)
}
}
}
}
}
})(l[i])
}if(x!=null){
x.onclick()
}
}
#7
最简单的加密,把开头的eval替换成alert就可以显示出解密后的结果了
#8
路过学习。
#9
上面全是错的....
首先是编码转换后的, 但是压缩状态(不含注释和空格)
下面是format后的版本
最后放上源码
官方提供的源码与pack中的有少许不同, 导致初始化时第一个不能选中
首先是编码转换后的, 但是压缩状态(不含注释和空格)
function $(d){return document.getElementById(d)}function g(d,v){if(v==undefined){if(d.style.display!="none"&&d.style.display!=""){return d.offsetHeight}o=d.style.display;d.style.display="block";v=parseInt(d.offsetHeight);d.style.display=o;return v}else{d.style.height=v+"px"}}function of(d,v){g(d,v);v=v/d.h;d.style.opacity=v;d.style.filter="alpha(opacity="+v*100+")"}function b(d){d=$(d);z=g(d);x=d.h;if(z>0){v=Math.round(z/d.s);v=(v<1)?z-1:z-v;of(d,v)}else{g(d,0);d.style.display="none";clearInterval(d.t)}}function e(d){d=$(d);z=g(d);x=d.h;d.style.display="block";if(z<x){v=Math.round((x-z)/d.s);v=(v<1)?z+1:v+z;of(d,v)}else{g(d,x);clearInterval(d.t)}}function Accordian(d,s,f){l=$(d).getElementsByTagName("div");a=[];for(i=0;i<l.length;i++){d=l[i];if(d.id.substr(d.id.indexOf("-"),d.id.length)=="-content"){a.push(d)}}x=null;for(i=0;i<l.length;i++){(function(h){c=h.id.substr(0,h.id.indexOf("-"));if(c+"-header"==h.id){c=$(c+"-content");c.style.display="none";c.style.overflow="hidden";c.h=g(c);c.s=(s==undefined)?7:s;h.f=f;h.c=a;if(h.className.match(new RegExp(f+"+"))){x=h}h.onclick=function(){for(j=0;j<this.c.length;j++){n=this.c[j].id;n=n.substr(0,n.indexOf("-"));d=$(n+"-header");n=$(n+"-content");s=d.className.split(new RegExp("\\s+"));for(p=0;p<s.length;p++){if(s[p]==""+d.f){s.splice(p,1);d.className=s.join(" ");break}}clearInterval(n.t);if(d.id==this.id){if(n.style.display=="none"){g(n,0);n.t=setInterval('e("'+n.id+'")',9)}d.className+=" "+d.f}else{if(n.style.display=="block"){n.t=setInterval('b("'+n.id+'")',9)}}}}}})(l[i])}if(x!=null){x.onclick()}}
下面是format后的版本
function $(d) {
return document.getElementById(d)
}
function g(d, v) {
if (v == undefined) {
if (d.style.display != "none" && d.style.display != "") {
return d.offsetHeight
}
o = d.style.display;
d.style.display = "block";
v = parseInt(d.offsetHeight);
d.style.display = o;
return v
} else {
d.style.height = v + "px"
}
}
function of(d, v) {
g(d, v);
v = v / d.h;
d.style.opacity = v;
d.style.filter = "alpha(opacity=" + v * 100 + ")"
}
function b(d) {
d = $(d);
z = g(d);
x = d.h;
if (z > 0) {
v = Math.round(z / d.s);
v = (v < 1) ? z - 1 : z - v;
of(d, v)
} else {
g(d, 0);
d.style.display = "none";
clearInterval(d.t)
}
}
function e(d) {
d = $(d);
z = g(d);
x = d.h;
d.style.display = "block";
if (z < x) {
v = Math.round((x - z) / d.s);
v = (v < 1) ? z + 1 : v + z;
of(d, v)
} else {
g(d, x);
clearInterval(d.t)
}
}
function Accordian(d, s, f) {
l = $(d).getElementsByTagName("div");
a = [];
for (i = 0; i < l.length; i++) {
d = l[i];
if (d.id.substr(d.id.indexOf("-"), d.id.length) == "-content") {
a.push(d)
}
}
x = null;
for (i = 0; i < l.length; i++) {
(function(h) {
c = h.id.substr(0, h.id.indexOf("-"));
if (c + "-header" == h.id) {
c = $(c + "-content");
c.style.display = "none";
c.style.overflow = "hidden";
c.h = g(c);
c.s = (s == undefined) ? 7 : s;
h.f = f;
h.c = a;
if (h.className.match(new RegExp(f + "+"))) {
x = h
}
h.onclick = function() {
for (j = 0; j < this.c.length; j++) {
n = this.c[j].id;
n = n.substr(0, n.indexOf("-"));
d = $(n + "-header");
n = $(n + "-content");
s = d.className.split(new RegExp("\\s+"));
for (p = 0; p < s.length; p++) {
if (s[p] == "" + d.f) {
s.splice(p, 1);
d.className = s.join(" ");
break
}
}
clearInterval(n.t);
if (d.id == this.id) {
if (n.style.display == "none") {
g(n, 0);
n.t = setInterval('e("' + n.id + '")', 9)
}
d.className += " " + d.f
} else {
if (n.style.display == "block") {
n.t = setInterval('b("' + n.id + '")', 9)
}
}
}
}
}
})(l[i])
}
if (x != null) {
x.onclick()
}
}
最后放上源码
/*
DezinerFolio.com Simple Accordians.
Author : G.S.Navin Raj Kumar
Website : http://dezinerfolio.com
*/
/*
* The Variable names have been compressed to achive a higher level of compression.
*/
// Prototype Method to get the element based on ID
function $(d){
return document.getElementById(d);
}
// set or get the current display style of the div
function dsp(d,v){
if(v==undefined){
return d.style.display;
}else{
d.style.display=v;
}
}
// set or get the height of a div.
function sh(d,v){
// if you are getting the height then display must be block to return the absolute height
if(v==undefined){
if(dsp(d)!='none'&& dsp(d)!=''){
return d.offsetHeight;
}
viz = d.style.visibility;
d.style.visibility = 'hidden';
o = dsp(d);
dsp(d,'block');
r = parseInt(d.offsetHeight);
dsp(d,o);
d.style.visibility = viz;
return r;
}else{
d.style.height=v;
}
}
/*
* Variable 'S' defines the speed of the accordian
* Variable 'T' defines the refresh rate of the accordian
*/
s=7;
t=10;
//Collapse Timer is triggered as a setInterval to reduce the height of the div exponentially.
function ct(d){
d = $(d);
if(sh(d)>0){
v = Math.round(sh(d)/d.s);
v = (v<1) ? 1 :v ;
v = (sh(d)-v);
sh(d,v+'px');
d.style.opacity = (v/d.maxh);
d.style.filter= 'alpha(opacity='+(v*100/d.maxh)+');';
}else{
sh(d,0);
dsp(d,'none');
clearInterval(d.t);
}
}
//Expand Timer is triggered as a setInterval to increase the height of the div exponentially.
function et(d){
d = $(d);
if(sh(d)<d.maxh){
v = Math.round((d.maxh-sh(d))/d.s);
v = (v<1) ? 1 :v ;
v = (sh(d)+v);
sh(d,v+'px');
d.style.opacity = (v/d.maxh);
d.style.filter= 'alpha(opacity='+(v*100/d.maxh)+');';
}else{
sh(d,d.maxh);
clearInterval(d.t);
}
}
// Collapse Initializer
function cl(d){
if(dsp(d)=='block'){
clearInterval(d.t);
d.t=setInterval('ct("'+d.id+'")',t);
}
}
//Expand Initializer
function ex(d){
if(dsp(d)=='none'){
dsp(d,'block');
d.style.height='0px';
clearInterval(d.t);
d.t=setInterval('et("'+d.id+'")',t);
}
}
// Removes Classname from the given div.
function cc(n,v){
s=n.className.split(/\s+/);
for(p=0;p<s.length;p++){
if(s[p]==v+n.tc){
s.splice(p,1);
n.className=s.join(' ');
break;
}
}
}
//Accordian Initializer
function Accordian(d,s,tc){
// get all the elements that have id as content
l=$(d).getElementsByTagName('div');
c=[];
for(i=0;i<l.length;i++){
h=l[i].id;
if(h.substr(h.indexOf('-')+1,h.length)=='content'){c.push(h);}
}
sel=null;
//then search through headers
for(i=0;i<l.length;i++){
h=l[i].id;
if(h.substr(h.indexOf('-')+1,h.length)=='header'){
d=$(h.substr(0,h.indexOf('-'))+'-content');
d.style.display='none';
d.style.overflow='hidden';
d.maxh =sh(d);
d.s=(s==undefined)? 7 : s;
h=$(h);
h.tc=tc;
h.c=c;
// set the onclick function for each header.
h.onclick = function(){
for(i=0;i<this.c.length;i++){
cn=this.c[i];
n=cn.substr(0,cn.indexOf('-'));
if((n+'-header')==this.id){
ex($(n+'-content'));
n=$(n+'-header');
cc(n,'__');
n.className=n.className+' '+n.tc;
}else{
cl($(n+'-content'));
cc($(n+'-header'),'');
}
}
}
if(h.className.match(/selected+/)!=undefined){ sel=h;}
}
}
if(sel!=undefined){sel.onclick();}
}
官方提供的源码与pack中的有少许不同, 导致初始化时第一个不能选中
#10
另:
使用document.write输出到页面上就会出现lidong2001的情况 在出现"<"号的地方被解释成了标签导致无法完全显示
我使用IE8调试, 将eval中的内容放入一个变量, 断点看到了完全的内容
使用document.write输出到页面上就会出现lidong2001的情况 在出现"<"号的地方被解释成了标签导致无法完全显示
我使用IE8调试, 将eval中的内容放入一个变量, 断点看到了完全的内容
#1
function.className$(d){return.classNamedocument.getElementById(d)}function.classNameg(d,v){if(v==undefined){if(d.style.display!="none"&&d.style.display!=""){return.classNamed.offsetHeight}o=d.style.display;d.style.display="block";v=parseInt(d.offsetHeight);d.style.display=o;return.classNamev}else{d.style.height=v+"px"}}function.classNameof(d,v){g(d,v);v=v/d.h;d.style.opacity=v;d.style.filter="alpha(opacity="+v*100+")"}function.classNameb(d){d=$(d);z=g(d);x=d.h;if(z>0){v=Math.round(z/d.s);v=(v.className<1)?z-1:z-v;of(d,v)}else{g(d,0);d.style.display="none";clearInterval(d.t)}}function.classNamee(d){d=$(d);z=g(d);x=d.h;d.style.display="block";if(z.className<x){v=Math.round((x-z)/d.s);v=(v.className<1)?z+1:v+z;of(d,v)}else{g(d,x);clearInterval(d.t)}}function.classNameAccordian(d,s,f){l=$(d).getElementsByTagName("div");a=[];for(i=0;i.className<l.length;i++){d=l[i];if(d.id.substr(d.id.indexOf("-"),d.id.length)=="-content"){a.push(d)}}x=null;for(i=0;i.className<l.length;i++){(function(h){c=h.id.substr(0,h.id.indexOf("-"));if(c+"-header"==h.id){c=$(c+"-content");c.style.display="none";c.style.overflow="hidden";c.h=g(c);c.s=(s==undefined)?7:s;h.f=f;h.c=a;if(h.className.match(new.classNameRegExp(f+"+"))){x=h}h.onclick=function(){for(j=0;j.className<this.c.length;j++){n=this.c[j].id;n=n.substr(0,n.indexOf("-"));d=$(n+"-header");n=$(n+"-content");s=d.className.split(new.classNameRegExp("\\s+"));for(p=0;p.className<s.length;p++){if(s[p]==""+d.f){s.splice(p,1);d.className=s.join(".className");break}}clearInterval(n.t);if(d.id==this.id){if(n.style.display=="none"){g(n,0);n.t=setInterval('e("'+n.id+'")',9)}d.className+=".className"+d.f}else{if(n.style.display=="block"){n.t=setInterval('b("'+n.id+'")',9)}}}}}})(l[i])}if(x!=null){x.onclick()}}
#2
解密了,都运行不了老。。。
#3
我提供给你们下载吧。。。
http://www.lszx8.com/accordian.pack.js
#4
function .className$(d){
return .classNamedocument.getElementById(d)
}function .classNameg(d,v){
if(v==undefined){
if(d.style.display!="none"&&d.style.display!=""){
return .classNamed.offsetHeight
}o=d.style.display;
d.style.display="block";
v=parseInt(d.offsetHeight);
d.style.display=o;
return .classNamev
}else {
d.style.height=v+"px"
}
}function .classNameof(d,v){
g(d,v);
v=v/d.h;
d.style.opacity=v;
d.style.filter="alpha(opacity="+v*100+")"
}function .classNameb(d){
d=$(d);
z=g(d);
x=d.h;
if(z>0){
v=Math.round(z/d.s);
v=(v.className<1)?z-1:z-v;
of(d,v)
}else {
g(d,0);
d.style.display="none";
clearInterval(d.t)
}
}function .classNamee(d){
d=$(d);
z=g(d);
x=d.h;
d.style.display="block";
if(z.className<x){
v=Math.round((x-z)/d.s);
v=(v.className<1)?z+1:v+z;
of(d,v)
}else {
g(d,x);
clearInterval(d.t)
}
}function .classNameAccordian(d,s,f){
l=$(d).getElementsByTagName("div");
a=[];
for(i=0;i.className<l.length;i++){
d=l[i];
if(d.id.substr(d.id.indexOf("-"),d.id.length)=="-content"){
a.push(d)
}
}x=null;
for(i=0;i.className<l.length;i++){
(function (h){
c=h.id.substr(0,h.id.indexOf("-"));
if(c+"-header"==h.id){
c=$(c+"-content");
c.style.display="none";
c.style.overflow="hidden";
c.h=g(c);
c.s=(s==undefined)?7:s;
h.f=f;
h.c=a;
if(h.className.match(new .classNameRegExp(f+"+"))){
x=h
}h.onclick=function (){
for(j=0;j.className<this.c.length;j++){
n=this.c[j].id;
n=n.substr(0,n.indexOf("-"));
d=$(n+"-header");
n=$(n+"-content");
s=d.className.split(new .classNameRegExp("\\s+"));
for(p=0;p.className<s.length;p++){
if(s[p]==""+d.f){
s.splice(p,1);
d.className=s.join(".className");
break
}
}clearInterval(n.t);
if(d.id==this.id){
if(n.style.display=="none"){
g(n,0);
n.t=setInterval('e("'+n.id+'")',9)
}d.className+=".className"+d.f
}else {
if(n.style.display=="block"){
n.t=setInterval('b("'+n.id+'")',9)
}
}
}
}
}
})(l[i])
}if(x!=null){
x.onclick()
}
}
#5
还是运行不了啊。。我前台是通过emailRequest调用的
#6
function $(d){
return document.getElementById(d)
}function g(d,v){
if(v==undefined){
if(d.style.display!="none"&&d.style.display!=""){
return d.offsetHeight
}o=d.style.display;
d.style.display="block";
v=parseInt(d.offsetHeight);
d.style.display=o;
return v
}else {
d.style.height=v+"px"
}
}function of(d,v){
g(d,v);
v=v/d.h;
d.style.opacity=v;
d.style.filter="alpha(opacity="+v*100+")"
}function b(d){
d=$(d);
z=g(d);
x=d.h;
if(z>0){
v=Math.round(z/d.s);
v=(v<1)?z-1:z-v;
of(d,v)
}else {
g(d,0);
d.style.display="none";
clearInterval(d.t)
}
}function e(d){
d=$(d);
z=g(d);
x=d.h;
d.style.display="block";
if(z<x){
v=Math.round((x-z)/d.s);
v=(v<1)?z+1:v+z;
of(d,v)
}else {
g(d,x);
clearInterval(d.t)
}
}function Accordian(d,s,f){
l=$(d).getElementsByTagName("div");
a=[];
for(i=0;i<l.length;i++){
d=l[i];
if(d.id.substr(d.id.indexOf("-"),d.id.length)=="-content"){
a.push(d)
}
}x=null;
for(i=0;i<l.length;i++){
(function (h){
c=h.id.substr(0,h.id.indexOf("-"));
if(c+"-header"==h.id){
c=$(c+"-content");
c.style.display="none";
c.style.overflow="hidden";
c.h=g(c);
c.s=(s==undefined)?7:s;
h.f=f;
h.c=a;
if(h.match(new RegExp(f+"+"))){
x=h
}h.onclick=function (){
for(j=0;j<this.c.length;j++){
n=this.c[j].id;
n=n.substr(0,n.indexOf("-"));
d=$(n+"-header");
n=$(n+"-content");
s=d.split(new RegExp("\\s+"));
for(p=0;p<s.length;p++){
if(s[p]==""+d.f){
s.splice(p,1);
d=s.join("");
break
}
}clearInterval(n.t);
if(d.id==this.id){
if(n.style.display=="none"){
g(n,0);
n.t=setInterval('e("'+n.id+'")',9)
}d+=""+d.f
}else {
if(n.style.display=="block"){
n.t=setInterval('b("'+n.id+'")',9)
}
}
}
}
}
})(l[i])
}if(x!=null){
x.onclick()
}
}
#7
最简单的加密,把开头的eval替换成alert就可以显示出解密后的结果了
#8
路过学习。
#9
上面全是错的....
首先是编码转换后的, 但是压缩状态(不含注释和空格)
下面是format后的版本
最后放上源码
官方提供的源码与pack中的有少许不同, 导致初始化时第一个不能选中
首先是编码转换后的, 但是压缩状态(不含注释和空格)
function $(d){return document.getElementById(d)}function g(d,v){if(v==undefined){if(d.style.display!="none"&&d.style.display!=""){return d.offsetHeight}o=d.style.display;d.style.display="block";v=parseInt(d.offsetHeight);d.style.display=o;return v}else{d.style.height=v+"px"}}function of(d,v){g(d,v);v=v/d.h;d.style.opacity=v;d.style.filter="alpha(opacity="+v*100+")"}function b(d){d=$(d);z=g(d);x=d.h;if(z>0){v=Math.round(z/d.s);v=(v<1)?z-1:z-v;of(d,v)}else{g(d,0);d.style.display="none";clearInterval(d.t)}}function e(d){d=$(d);z=g(d);x=d.h;d.style.display="block";if(z<x){v=Math.round((x-z)/d.s);v=(v<1)?z+1:v+z;of(d,v)}else{g(d,x);clearInterval(d.t)}}function Accordian(d,s,f){l=$(d).getElementsByTagName("div");a=[];for(i=0;i<l.length;i++){d=l[i];if(d.id.substr(d.id.indexOf("-"),d.id.length)=="-content"){a.push(d)}}x=null;for(i=0;i<l.length;i++){(function(h){c=h.id.substr(0,h.id.indexOf("-"));if(c+"-header"==h.id){c=$(c+"-content");c.style.display="none";c.style.overflow="hidden";c.h=g(c);c.s=(s==undefined)?7:s;h.f=f;h.c=a;if(h.className.match(new RegExp(f+"+"))){x=h}h.onclick=function(){for(j=0;j<this.c.length;j++){n=this.c[j].id;n=n.substr(0,n.indexOf("-"));d=$(n+"-header");n=$(n+"-content");s=d.className.split(new RegExp("\\s+"));for(p=0;p<s.length;p++){if(s[p]==""+d.f){s.splice(p,1);d.className=s.join(" ");break}}clearInterval(n.t);if(d.id==this.id){if(n.style.display=="none"){g(n,0);n.t=setInterval('e("'+n.id+'")',9)}d.className+=" "+d.f}else{if(n.style.display=="block"){n.t=setInterval('b("'+n.id+'")',9)}}}}}})(l[i])}if(x!=null){x.onclick()}}
下面是format后的版本
function $(d) {
return document.getElementById(d)
}
function g(d, v) {
if (v == undefined) {
if (d.style.display != "none" && d.style.display != "") {
return d.offsetHeight
}
o = d.style.display;
d.style.display = "block";
v = parseInt(d.offsetHeight);
d.style.display = o;
return v
} else {
d.style.height = v + "px"
}
}
function of(d, v) {
g(d, v);
v = v / d.h;
d.style.opacity = v;
d.style.filter = "alpha(opacity=" + v * 100 + ")"
}
function b(d) {
d = $(d);
z = g(d);
x = d.h;
if (z > 0) {
v = Math.round(z / d.s);
v = (v < 1) ? z - 1 : z - v;
of(d, v)
} else {
g(d, 0);
d.style.display = "none";
clearInterval(d.t)
}
}
function e(d) {
d = $(d);
z = g(d);
x = d.h;
d.style.display = "block";
if (z < x) {
v = Math.round((x - z) / d.s);
v = (v < 1) ? z + 1 : v + z;
of(d, v)
} else {
g(d, x);
clearInterval(d.t)
}
}
function Accordian(d, s, f) {
l = $(d).getElementsByTagName("div");
a = [];
for (i = 0; i < l.length; i++) {
d = l[i];
if (d.id.substr(d.id.indexOf("-"), d.id.length) == "-content") {
a.push(d)
}
}
x = null;
for (i = 0; i < l.length; i++) {
(function(h) {
c = h.id.substr(0, h.id.indexOf("-"));
if (c + "-header" == h.id) {
c = $(c + "-content");
c.style.display = "none";
c.style.overflow = "hidden";
c.h = g(c);
c.s = (s == undefined) ? 7 : s;
h.f = f;
h.c = a;
if (h.className.match(new RegExp(f + "+"))) {
x = h
}
h.onclick = function() {
for (j = 0; j < this.c.length; j++) {
n = this.c[j].id;
n = n.substr(0, n.indexOf("-"));
d = $(n + "-header");
n = $(n + "-content");
s = d.className.split(new RegExp("\\s+"));
for (p = 0; p < s.length; p++) {
if (s[p] == "" + d.f) {
s.splice(p, 1);
d.className = s.join(" ");
break
}
}
clearInterval(n.t);
if (d.id == this.id) {
if (n.style.display == "none") {
g(n, 0);
n.t = setInterval('e("' + n.id + '")', 9)
}
d.className += " " + d.f
} else {
if (n.style.display == "block") {
n.t = setInterval('b("' + n.id + '")', 9)
}
}
}
}
}
})(l[i])
}
if (x != null) {
x.onclick()
}
}
最后放上源码
/*
DezinerFolio.com Simple Accordians.
Author : G.S.Navin Raj Kumar
Website : http://dezinerfolio.com
*/
/*
* The Variable names have been compressed to achive a higher level of compression.
*/
// Prototype Method to get the element based on ID
function $(d){
return document.getElementById(d);
}
// set or get the current display style of the div
function dsp(d,v){
if(v==undefined){
return d.style.display;
}else{
d.style.display=v;
}
}
// set or get the height of a div.
function sh(d,v){
// if you are getting the height then display must be block to return the absolute height
if(v==undefined){
if(dsp(d)!='none'&& dsp(d)!=''){
return d.offsetHeight;
}
viz = d.style.visibility;
d.style.visibility = 'hidden';
o = dsp(d);
dsp(d,'block');
r = parseInt(d.offsetHeight);
dsp(d,o);
d.style.visibility = viz;
return r;
}else{
d.style.height=v;
}
}
/*
* Variable 'S' defines the speed of the accordian
* Variable 'T' defines the refresh rate of the accordian
*/
s=7;
t=10;
//Collapse Timer is triggered as a setInterval to reduce the height of the div exponentially.
function ct(d){
d = $(d);
if(sh(d)>0){
v = Math.round(sh(d)/d.s);
v = (v<1) ? 1 :v ;
v = (sh(d)-v);
sh(d,v+'px');
d.style.opacity = (v/d.maxh);
d.style.filter= 'alpha(opacity='+(v*100/d.maxh)+');';
}else{
sh(d,0);
dsp(d,'none');
clearInterval(d.t);
}
}
//Expand Timer is triggered as a setInterval to increase the height of the div exponentially.
function et(d){
d = $(d);
if(sh(d)<d.maxh){
v = Math.round((d.maxh-sh(d))/d.s);
v = (v<1) ? 1 :v ;
v = (sh(d)+v);
sh(d,v+'px');
d.style.opacity = (v/d.maxh);
d.style.filter= 'alpha(opacity='+(v*100/d.maxh)+');';
}else{
sh(d,d.maxh);
clearInterval(d.t);
}
}
// Collapse Initializer
function cl(d){
if(dsp(d)=='block'){
clearInterval(d.t);
d.t=setInterval('ct("'+d.id+'")',t);
}
}
//Expand Initializer
function ex(d){
if(dsp(d)=='none'){
dsp(d,'block');
d.style.height='0px';
clearInterval(d.t);
d.t=setInterval('et("'+d.id+'")',t);
}
}
// Removes Classname from the given div.
function cc(n,v){
s=n.className.split(/\s+/);
for(p=0;p<s.length;p++){
if(s[p]==v+n.tc){
s.splice(p,1);
n.className=s.join(' ');
break;
}
}
}
//Accordian Initializer
function Accordian(d,s,tc){
// get all the elements that have id as content
l=$(d).getElementsByTagName('div');
c=[];
for(i=0;i<l.length;i++){
h=l[i].id;
if(h.substr(h.indexOf('-')+1,h.length)=='content'){c.push(h);}
}
sel=null;
//then search through headers
for(i=0;i<l.length;i++){
h=l[i].id;
if(h.substr(h.indexOf('-')+1,h.length)=='header'){
d=$(h.substr(0,h.indexOf('-'))+'-content');
d.style.display='none';
d.style.overflow='hidden';
d.maxh =sh(d);
d.s=(s==undefined)? 7 : s;
h=$(h);
h.tc=tc;
h.c=c;
// set the onclick function for each header.
h.onclick = function(){
for(i=0;i<this.c.length;i++){
cn=this.c[i];
n=cn.substr(0,cn.indexOf('-'));
if((n+'-header')==this.id){
ex($(n+'-content'));
n=$(n+'-header');
cc(n,'__');
n.className=n.className+' '+n.tc;
}else{
cl($(n+'-content'));
cc($(n+'-header'),'');
}
}
}
if(h.className.match(/selected+/)!=undefined){ sel=h;}
}
}
if(sel!=undefined){sel.onclick();}
}
官方提供的源码与pack中的有少许不同, 导致初始化时第一个不能选中
#10
另:
使用document.write输出到页面上就会出现lidong2001的情况 在出现"<"号的地方被解释成了标签导致无法完全显示
我使用IE8调试, 将eval中的内容放入一个变量, 断点看到了完全的内容
使用document.write输出到页面上就会出现lidong2001的情况 在出现"<"号的地方被解释成了标签导致无法完全显示
我使用IE8调试, 将eval中的内容放入一个变量, 断点看到了完全的内容