<!--
//判断浏览器类型是不是IE
var yy_$scrllo=function(){
var MSIE;
this.MSIE = false;
if(navigator.userAgent.indexOf('MSIE')>=0) this.MSIE = true;
}
////返回整个文档的高度和宽度  
yy_$scrllo.prototype.$PageSize=function(){
var yScroll;
//window.innerHeight窗口的文档显示区的高度
if (window.innerHeight && window.scrollMaxY) { 
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){
yScroll = document.body.scrollHeight;
} else {
yScroll = document.body.offsetHeight;
}
return yScroll;
}yy_$scrllo.prototype.$w_PageSize=function(){
var xScroll;
if (window.innerHeight && window.scrollMaxX) {
xScroll = window.innerWidth + window.scrollMaxX;
} else if (document.body.scrollWidth > document.body.offsetWidth){
xScroll = document.body.scrollWidth;
} else {
xScroll = document.body.offsetWidth;
}
return xScroll;
}
//页面高度减去value的高度
yy_$scrllo.prototype.$value_Size=function(value){
return (parseInt(this.$PageSize())-parseInt(value))+"px";
}
//
yy_$scrllo.prototype.$Setpage_size=function($parent,value){
if(typeof($parent)=="string")$parent=document.getElementById($parent);
$parent.style.height=this.$value_Size(value);
}//
yy_$scrllo.prototype.$Setpage_width=function($parent,value){
if(typeof($parent)=="string")$parent=document.getElementById($parent);
$parent.style.width=(parseInt(this.$w_PageSize(),10)-parseInt(value,10))+"px"
}
yy_$scrllo.prototype.$creat_scroll = function(){
var $scrllo_demo=this.$DIV(document.body,"div","","yy_Parent_DIV","","");
this.$DIV($scrllo_demo,"div","","yy_scroll_DIV","","");
}
yy_$scrllo.prototype.$_direction=function(x_obj){
if(typeof(x_obj)=="string")
x_obj=document.getElementById(x_obj).getElementsByTagName("span")[0].style;
try {
if(x_obj.getPropertyValue("background-position")=="0px 0px"){
x_obj.cssText="background-position:0px -16px";
parent.document.getElementsByTagName("frameset")[0].cols = '0,*';
}else{
x_obj.cssText="background-position:0px 0px";
parent.document.getElementsByTagName("frameset")[0].cols = '210,*';
}}catch(e){
if(x_obj.backgroundPositionY=="0px"){
x_obj.backgroundPositionY="-16px"
parent.document.getElementsByTagName("frameset")[0].cols = '0,*';
}else{
x_obj.backgroundPositionY="0px"
parent.document.getElementsByTagName("frameset")[0].cols = '210,*';
}}
}
yy_$scrllo.prototype.$object = function($parent){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
if($parent)return true; else return false;
}
yy_$scrllo.prototype.$serch = function($parent,$item){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
try{return eval("$parent."+$item+";");}catch(e){}
}
yy_$scrllo.prototype.clear=function($parent,$inner){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
$parent.innerHTML=$inner;
}
yy_$scrllo.prototype.$valume=function($parent,$valume){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
try{
eval("$parent."+$valume);
}catch(e){
eval("$parent"+$valume);
}
}
yy_$scrllo.prototype.$radios=function($parent){
if(typeof($parent)=="string")
$parent=document.getElementsByName($parent);
for(tp=0;tp<$parent.length;tp++){
if($parent[tp].checked)return $parent[tp].value;
}
}
yy_$scrllo.prototype.$DIV=function($parent,$Elemt,$id,$class,$display,$title){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
var $DivDome = document.createElement($Elemt);
if($id!="")$DivDome.name=$DivDome.id=$id;
if($class!="")$DivDome.className=$class;
$DivDome.style.display=$display;
if($title!="")$DivDome.title=$title;
$parent.appendChild($DivDome);
return $DivDome;
}
yy_$scrllo.prototype.$A=function($parent,$id,$class,href,$title,$value){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
var $Ahref=this.$DIV($parent,"a",$id,$class,"",$title);
$Ahref.href=href;
this.clear($Ahref,($value||""));
return $Ahref;
}
yy_$scrllo.prototype.Butten=function($parent,$id,$value,$click,$disabled,$title,$width,$onfouce,$class){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
var $Button=document.createElement("input");
$Button.type="button";
if($id!="")$Button.name=$Button.id=$id;
$Button.className=$class||"Butten";
$Button.style.width=$width;
$Button.value=$value;
$Button.disabled=$disabled||0;
if($title!="")$Button.title=$title;
$Button["onmouseover"]=function(){this.className=($class||"Butten")+"_hover"};
$Button["onmouseout"]=function(){this.className=$class||"Butten"};
$Button["onclick"]=function(){eval($click)};
$parent.appendChild($Button);
if($onfouce&&!$disabled)$Button.focus();
return $Button;
}
yy_$scrllo.prototype.Input=function($parent,$id,$type,$width,$value,$chang,$click,$onKeyDown,$class,$title,$onRex){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
var $Input=document.createElement("input");
$Input.type=$type;
if($id!="")$Input.name=$Input.id=$id;
$Input.style.width=$width;
$Input.value=$value;
$Input.autocomplete="off";
if($class!="")$Input.className=$class;
if($title!="")$Input.title=$title;
$parent.appendChild($Input);
$Input["onfocus"]=function(){$Input.select();};
$Input["onclick"]=function(){eval($click)};
$Input["onkeyup"]=function(){eval($onRex||"");};
$Input["ondrag"]=function(){return false;};
$parent["onkeydown"]=function(event){if((window.event||event).keyCode==13) eval($onKeyDown);};
try{$Input.addEventListener('input',function(){eval($onRex||"");eval($chang)}, false);
}catch(e){$Input["onpropertychange"]=function(){eval($onRex||"");eval($chang)};}
return $Input;
}
yy_$scrllo.prototype.radio=function($parent,$id,$name,$type,$value,$click,$class,$title){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
var $radio = null;
try{$radio=document.createElement('<input name="'+$name+'" id="'+$id+'" >');}catch(e){}
if(!$radio){$radio=document.createElement("input"); $radio.name=$name; $radio.id=$id;}
  $radio.type=$type;
$radio.value=$value;
if($class!="")$radio.className=$class;
if($title!="")$radio.title=$title;
$radio["onclick"]=function(){eval($click)};
$parent.appendChild($radio);
}
yy_$scrllo.prototype.ImageButten=function($parent,$id,$class,$value,$click,$title,$disabled){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
var $DivDome=document.createElement("span");
if($id!="")$DivDome.id=$DivDome.name=$id;
if($class!="")$DivDome.className=$class;
$DivDome.innerHTML=$value;
if($title!="")$DivDome.title=$title;
if(!$disabled){
$DivDome["onmouseover"]=function(){this.className=$class+"_hover"};
$DivDome["onmouseout"]=function(){this.className=$class};
$DivDome["onclick"]=function(){eval($click)};
}
$parent.appendChild($DivDome);
return $DivDome;
}
yy_$scrllo.prototype.ClickSelect=function($parent,$id,$class,$value,$change,$selected,$title,$size){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
var $Select=document.createElement("select");
if($id!="")$Select.id=$Select.name=$id;
if($class!="")$Select.className=$class;
if($title!="")$Select.title=$title;
if($size)$Select.size=$size;
$Select["onchange"]=function(){eval($change)};
$parent.appendChild($Select);
this.AddOptiones($Select,$value,$selected)
return $Select;
}
yy_$scrllo.prototype.AddOptiones=function($parent,$value,$selected){
if($value.length){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
for(tp=0;tp<$value.length;tp++){
this.ClickOption($parent,unescape($value[tp]).split(","));
if(unescape($value[tp]).search($selected)>=0) $parent.options[tp].selected = true;
}}
}
yy_$scrllo.prototype.ClickOption=function($parent,$text){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
var $option=document.createElement("option");
$option.text=$text[0].replace(/\|/g,"");
$option.value=$text[1];
try{
$parent.add($option);
}catch(e){
$parent.appendChild($option);
}
}
yy_$scrllo.prototype.iframes=function($parent,$id,$display,$scrolling,$frameborder,$src,$class){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
var $iframe=document.createElement("iframe");
if($id!="")$iframe.id=$iframe.name=$id;
if($class!="")$iframe.className=$class;
$iframe.style.display=$display;
$iframe.scrolling=$scrolling;
$iframe.frameBorder=$frameborder;
$iframe.src=$src;
$parent.appendChild($iframe);
return $iframe;
}
yy_$scrllo.prototype.$Define_Regexp=function($parent,$value,$flags){
if(typeof($parent)=="string")
$parent=document.getElementById($parent);
var $re_exp,$pattern;
switch($value){
case 0: $pattern="[^0-9\.]"; break;
case 1: $pattern="[^a-zA-Z0-9_\u4e00-\u9fa5]"; break;
}
$re_exp=new RegExp($pattern,$flags);
if($re_exp.test($parent.value))$parent.value=$parent.value.replace($re_exp,"");
}
yy_$scrllo.prototype.HtmlEcode=function($str,$type){
$str=$str.toString();
if($type){
$str=$str.replace(/\\/g,"\\\\");
$str=$str.replace(/\&amp\;/g,"\&");
$str=$str.replace(/&lt;/g,"<");
$str=$str.replace(/&gt;/g,">");
$str=$str.replace(/\'/g,"\\\'");
}else{
$str=$str.replace(/&/g,"&amp;");
$str=$str.replace(/</g,"&lt;");
$str=$str.replace(/>/g,"&gt;");
}
return $str;
}
yy_$scrllo.prototype.$indexOf=function($array,sub_str,_start){
var ta,rt,d="|";
if(_start!=null){ta=$array.slice(_start);rt=_start;}else{ta=$array;rt=0;}
var str=d+ta.join(d)+d,t=str.indexOf(d+sub_str+d);
if(t==-1)return -1;rt+=str.slice(0,t).replace(/[^\|]/g,"").length;
return rt;
}
这是一个框架的基础类,我自己加了一点注释,后面看得有点晕,希望高手给注解一下,呵呵

解决方案 »

  1.   

    lz自己下载一个javascript的chm文档,一个一个查着看。看完了应该会学不少东西
      

  2.   

    的确,下个比较全的JavaScript文档看看
      

  3.   

    JavaScript文档看一下吧。再不懂网上查吧。这样影响深刻
      

  4.   

    如果能注释得了的话,自己写个框架就基本没有问题了
    呵呵,先看看这段吧,我没有弄明白
    //页面高度减去value的高度
    yy_$scrllo.prototype.$value_Size=function(value){
    return (parseInt(this.$PageSize())-parseInt(value))+"px";
    }
    //
    yy_$scrllo.prototype.$Setpage_size=function($parent,value){
    if(typeof($parent)=="string")$parent=document.getElementById($parent);
    $parent.style.height=this.$value_Size(value);
    }//
    yy_$scrllo.prototype.$Setpage_width=function($parent,value){
    if(typeof($parent)=="string")$parent=document.getElementById($parent);
    $parent.style.width=(parseInt(this.$w_PageSize(),10)-parseInt(value,10))+"px"
    }