Manyou诚邀开发者加盟 | 常见问题
《站长》俱乐部官方群公布 城市联络员机会多多
立即免费下载 Discuz!7.0.0 正式版
安装升级指南 | 用户手册 | 新手建站学堂
基于.net架构的Discuz!NT2.6正式版发布
Comsenz公司2009年招贤纳士,期待您的加盟
Discuz!收费服务内容及价格
7月重庆、成都、西安三地社区运营实战特训速报名
Discuz!/UCHome 专用官方虚拟主机
牧场新服一起联运:豆浆机免费带回家
基于Discuz!的免费论坛空间5D6D
康盛创想《站长》俱乐部18城市互动之旅报名ing
返回列表 回复 发帖

[求助]js问题, 圆角层

正在改一个插件
用以下js
在我的网站首页上面没问题,可是用在模版却不好用,很奇怪,不知道为什么。
哪位高手帮帮忙
  1. /* Nifty Corners Cube - rounded corners with CSS and Javascript
  2. Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.

  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10. GNU General Public License for more details.

  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  14. */

  15. var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);
  16. var niftyCss=false;

  17. String.prototype.find=function(what){
  18. return(this.indexOf(what)>=0 ? true : false);
  19. }

  20. var oldonload=window.onload;
  21. if(typeof(NiftyLoad)!='function') NiftyLoad=function(){};
  22. if(typeof(oldonload)=='function')
  23.     window.onload=function(){oldonload();AddCss();NiftyLoad()};
  24. else window.onload=function(){AddCss();NiftyLoad()};

  25. function AddCss(){
  26. niftyCss=true;
  27. var l=CreateEl("link");
  28. l.setAttribute("type","text/css");
  29. l.setAttribute("rel","stylesheet");
  30. l.setAttribute("href","niftyCorners.css");
  31. l.setAttribute("media","screen");
  32. document.getElementsByTagName("head")[0].appendChild(l);
  33. }

  34. function Nifty(selector,options){
  35. if(niftyOk==false) return;
  36. if(niftyCss==false) AddCss();
  37. var i,v=selector.split(","),h=0;
  38. if(options==null) options="";
  39. if(options.find("fixed-height"))
  40.     h=getElementsBySelector(v[0])[0].offsetHeight;
  41. for(i=0;i<v.length;i++)
  42.     Rounded(v[i],options);
  43. if(options.find("height")) SameHeight(selector,h);
  44. }

  45. function Rounded(selector,options){
  46. var i,top="",bottom="",v=new Array();
  47. if(options!=""){
  48.     options=options.replace("left","tl bl");
  49.     options=options.replace("right","tr br");
  50.     options=options.replace("top","tr tl");
  51.     options=options.replace("bottom","br bl");
  52.     options=options.replace("transparent","alias");
  53.     if(options.find("tl")){
  54.         top="both";
  55.         if(!options.find("tr")) top="left";
  56.         }
  57.     else if(options.find("tr")) top="right";
  58.     if(options.find("bl")){
  59.         bottom="both";
  60.         if(!options.find("br")) bottom="left";
  61.         }
  62.     else if(options.find("br")) bottom="right";
  63.     }
  64. if(top=="" && bottom=="" && !options.find("none")){top="both";bottom="both";}
  65. v=getElementsBySelector(selector);
  66. for(i=0;i<v.length;i++){
  67.     FixIE(v[i]);
  68.     if(top!="") AddTop(v[i],top,options);
  69.     if(bottom!="") AddBottom(v[i],bottom,options);
  70.     }
  71. }

  72. function AddTop(el,side,options){
  73. var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
  74. d.style.marginLeft="-"+getPadding(el,"Left")+"px";
  75. d.style.marginRight="-"+getPadding(el,"Right")+"px";
  76. if(options.find("alias") || (color=getBk(el))=="transparent"){
  77.     color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
  78.     }
  79. else{
  80.     bk=getParentBk(el); border=Mix(color,bk);
  81.     }
  82. d.style.background=bk;
  83. d.className="niftycorners";
  84. p=getPadding(el,"Top");
  85. if(options.find("small")){
  86.     d.style.marginBottom=(p-2)+"px";
  87.     btype+="s"; lim=2;
  88.     }
  89. else if(options.find("big")){
  90.     d.style.marginBottom=(p-10)+"px";
  91.     btype+="b"; lim=8;
  92.     }
  93. else d.style.marginBottom=(p-5)+"px";
  94. for(i=1;i<=lim;i++)
  95.     d.appendChild(CreateStrip(i,side,color,border,btype));
  96. el.style.paddingTop="0";
  97. el.insertBefore(d,el.firstChild);
  98. }

  99. function AddBottom(el,side,options){
  100. var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
  101. d.style.marginLeft="-"+getPadding(el,"Left")+"px";
  102. d.style.marginRight="-"+getPadding(el,"Right")+"px";
  103. if(options.find("alias") || (color=getBk(el))=="transparent"){
  104.     color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
  105.     }
  106. else{
  107.     bk=getParentBk(el); border=Mix(color,bk);
  108.     }
  109. d.style.background=bk;
  110. d.className="niftycorners";
  111. p=getPadding(el,"Bottom");
  112. if(options.find("small")){
  113.     d.style.marginTop=(p-2)+"px";
  114.     btype+="s"; lim=2;
  115.     }
  116. else if(options.find("big")){
  117.     d.style.marginTop=(p-10)+"px";
  118.     btype+="b"; lim=8;
  119.     }
  120. else d.style.marginTop=(p-5)+"px";
  121. for(i=lim;i>0;i--)
  122.     d.appendChild(CreateStrip(i,side,color,border,btype));
  123. el.style.paddingBottom=0;
  124. el.appendChild(d);
  125. }

  126. function CreateStrip(index,side,color,border,btype){
  127. var x=CreateEl("b");
  128. x.className=btype+index;
  129. x.style.backgroundColor=color;
  130. x.style.borderColor=border;
  131. if(side=="left"){
  132.     x.style.borderRightWidth="0";
  133.     x.style.marginRight="0";
  134.     }
  135. else if(side=="right"){
  136.     x.style.borderLeftWidth="0";
  137.     x.style.marginLeft="0";
  138.     }
  139. return(x);
  140. }

  141. function CreateEl(x){
  142. return(document.createElement(x));
  143. }

  144. function FixIE(el){
  145. if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
  146.     el.style.display="inline-block";
  147. }

  148. function SameHeight(selector,maxh){
  149. var i,v=selector.split(","),t,j,els=[],gap;
  150. for(i=0;i<v.length;i++){
  151.     t=getElementsBySelector(v[i]);
  152.     els=els.concat(t);
  153.     }
  154. for(i=0;i<els.length;i++){
  155.     if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
  156.     els[i].style.height="auto";
  157.     }
  158. for(i=0;i<els.length;i++){
  159.     gap=maxh-els[i].offsetHeight;
  160.     if(gap>0){
  161.         t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px";
  162.         nc=els[i].lastChild;
  163.         if(nc.className=="niftycorners")
  164.             els[i].insertBefore(t,nc);
  165.         else els[i].appendChild(t);
  166.         }
  167.     }
  168. }

  169. function getElementsBySelector(selector){
  170. var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
  171. if(selector.find("#")){ //id selector like "tag#id"
  172.     if(selector.find(" ")){  //descendant selector like "tag#id tag"
  173.         s=selector.split(" ");
  174.         var fs=s[0].split("#");
  175.         if(fs.length==1) return(objlist);
  176.         f=document.getElementById(fs[1]);
  177.         if(f){
  178.             v=f.getElementsByTagName(s[1]);
  179.             for(i=0;i<v.length;i++) objlist.push(v[i]);
  180.             }
  181.         return(objlist);
  182.         }
  183.     else{
  184.         s=selector.split("#");
  185.         tag=s[0];
  186.         selid=s[1];
  187.         if(selid!=""){
  188.             f=document.getElementById(selid);
  189.             if(f) objlist.push(f);
  190.             return(objlist);
  191.             }
  192.         }
  193.     }
  194. if(selector.find(".")){      //class selector like "tag.class"
  195.     s=selector.split(".");
  196.     tag=s[0];
  197.     selclass=s[1];
  198.     if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
  199.         s=selclass.split(" ");
  200.         selclass=s[0];
  201.         tag2=s[1];
  202.         }
  203.     }
  204. var v=document.getElementsByTagName(tag);  // tag selector like "tag"
  205. if(selclass==""){
  206.     for(i=0;i<v.length;i++) objlist.push(v[i]);
  207.     return(objlist);
  208.     }
  209. for(i=0;i<v.length;i++){
  210.     c=v[i].className.split(" ");
  211.     for(j=0;j<c.length;j++){
  212.         if(c[j]==selclass){
  213.             if(tag2=="") objlist.push(v[i]);
  214.             else{
  215.                 v2=v[i].getElementsByTagName(tag2);
  216.                 for(k=0;k<v2.length;k++) objlist.push(v2[k]);
  217.                 }
  218.             }
  219.         }
  220.     }
  221. return(objlist);
  222. }

  223. function getParentBk(x){
  224. var el=x.parentNode,c;
  225. while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
  226.     el=el.parentNode;
  227. if(c=="transparent") c="#FFFFFF";
  228. return(c);
  229. }

  230. function getBk(x){
  231. var c=getStyleProp(x,"backgroundColor");
  232. if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
  233.     return("transparent");
  234. if(c.find("rgb")) c=rgb2hex(c);
  235. return(c);
  236. }

  237. function getPadding(x,side){
  238. var p=getStyleProp(x,"padding"+side);
  239. if(p==null || !p.find("px")) return(0);
  240. return(parseInt(p));
  241. }

  242. function getStyleProp(x,prop){
  243. if(x.currentStyle)
  244.     return(x.currentStyle[prop]);
  245. if(document.defaultView.getComputedStyle)
  246.     return(document.defaultView.getComputedStyle(x,'')[prop]);
  247. return(null);
  248. }

  249. function rgb2hex(value){
  250. var hex="",v,h,i;
  251. var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
  252. var h=regexp.exec(value);
  253. for(i=1;i<4;i++){
  254.     v=parseInt(h[i]).toString(16);
  255.     if(v.length==1) hex+="0"+v;
  256.     else hex+=v;
  257.     }
  258. return("#"+hex);
  259. }

  260. function Mix(c1,c2){
  261. var i,step1,step2,x,y,r=new Array(3);
  262. if(c1.length==4)step1=1;
  263. else step1=2;
  264. if(c2.length==4) step2=1;
  265. else step2=2;
  266. for(i=0;i<3;i++){
  267.     x=parseInt(c1.substr(1+step1*i,step1),16);
  268.     if(step1==1) x=16*x+x;
  269.     y=parseInt(c2.substr(1+step2*i,step2),16);
  270.     if(step2==1) y=16*y+y;
  271.     r[i]=Math.floor((x*50+y*50)/100);
  272.     r[i]=r[i].toString(16);
  273.     if(r[i].length==1) r[i]="0"+r[i];
  274.     }
  275. return("#"+r[0]+r[1]+r[2]);
  276. }
复制代码
弄不懂啊   。。。
请看我的网站
http://www.uwcssa.com/aboutus.html
那个about us div是圆角的,就是用这个js
可是在我的论坛中,却不能使用这个js
很奇怪
返回列表