java常用方法

public static int byte2int(byte b) {
    int i = b & 0x07f;
    if (b < 0) {
        i |= 0x80;
    }
    return i;
}

 

//运行代码
function runEx(cod1)  {
     cod=document.getElementById(cod1)
      var code=cod.value;
      if (code!=""){
          var newwin=window.open('','','');  
          newwin.opener = null 
          newwin.document.write(code);  
          newwin.document.close();
    }
}

 

//复制代码
function doCopy(ID) { 
    if (document.all){
         textRange = document.getElementById(ID).createTextRange(); 
         textRange.execCommand("Copy"); 
    }
    else{
         //alert("此功能只能在IE上有效");
         copyToClipboard(document.getElementById(ID).value);
    }
}

 

//保存代码
function saveCode(cod1) {
    cod=document.getElementById(cod1)
    var code=cod.value;
    if (code!=""){
        var winname = window.open('', '_blank', 'top=10000');
        winname.document.open('text/html', 'replace');
        winname.document.write(code);
        winname.document.execCommand('saveas','','code.htm');
        winname.close();
    }
} 

 

posted @ 2014-03-04 16:03  jieyuefeng  阅读(202)  评论(0编辑  收藏  举报