您现在的位置是:网站首页> 编程资料编程资料

PBlog2 公用JS代码_正则表达式_

2023-05-25 454人已围观

简介 PBlog2 公用JS代码_正则表达式_

复制代码 代码如下:

//PBlog2 公用JS代码
//Author:PuterJam

//查找网页内宽度太大的图片进行缩放以及PNG纠正
 function ReImgSize(){
  for (i=0;i   {
   if (document.all){
 if (document.images[i].width>500)
  {
       document.images[i].width="500"
       document.images[i].outerHTML=''+document.images[i].outerHTML+''
    }
   }
  else{
 if (document.images[i].width>400) {
   document.images[i].title="在新窗口打开图片"
   document.images[i].style.cursor="pointer"
   document.images[i].onclick=function(e){window.open(this.src)}
 }
  }
  }
 }

//AccessKey 转换For IE Design By PuterJam
  var NKey=new Array()
  var KeyCode=new Array()
  var KeyInit=false
//======== keyCode ============
  KeyCode["1"]=49
  KeyCode["2"]=50
  KeyCode["3"]=51
  KeyCode["["]=219
  KeyCode["]"]=221
  KeyCode[","]=188
  KeyCode["."]=190
  var EKey="abcdefghijklmnopqrstuwvxyz"
  for (i=0;i<26;i++){
    KeyCode[EKey.substr(i,1)]=65+i
  }

  function PressKey(){
  if (document.all) {
    for (i=0;i     if (window.event.altKey && window.event.keyCode==NKey[i].Code) {NKey[i].Object.blur();NKey[i].Object.click()}
    }

 }
  }

  function AccessKey(Code,Object){
   this.Code=Code
   this.Object=Object
  }


  function initAccessKey(){
  if (document.all && !KeyInit) {
     for (i=0;i       if (document.links[i].accessKey) {
         NKey[NKey.length]=new AccessKey(KeyCode[document.links[i].accessKey.toLowerCase()],document.links[i])
       }
     }
  }
  KeyInit=true
  }

//初始化JS代码
function initJS(){
 ReImgSize() //自动缩放代码
 initAccessKey()  //转换AccessKey For IE
}

//让Mozilla支持innerText
try{
 HTMLElement.prototype.__defineGetter__
 (
 "innerText",
 function ()
 {
  var anyString = "";

  var childS = this.childNodes;
   for(var i=0; i   {
    if(childS[i].nodeType==1)
    anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
    else if(childS[i].nodeType==3)
    anyString += childS[i].nodeValue;
   }
   return anyString;
 }
 );
}
catch(e){}

//判断是否是IE
function isIE(){
 if (navigator.appName!="Microsoft Internet Explorer") {return false}
 return true
}
//显示隐藏主题
function TopicShow(e,TopicID){
  e.className=(e.className=="BttnC")?"BttnE":"BttnC"
  document.getElementById(TopicID).style.display=(e.className=="BttnC")?"":"none"
  ReImgSize()
}
//打开新窗口
function popnew(url,title,width,height){
    var w = 1024;
    var h = 768;

    if (document.all || document.layers){
        w = screen.availWidth;
        h = screen.availHeight;
    }

    var leftPos = (w/2-width/2);
    var topPos = (h/2.3-height/2.3);

    window.open(url,title,"width="+width+",height="+height+",top="+topPos+",left="+leftPos+",scrollbars=no,resizable=no,status=no")
}
//运行代码
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上有效")
 }
}
var MediaTemp=new Array()
function MediaShow(strType,strID,strURL,intWidth,intHeight)
{
 var tmpstr
 if (MediaTemp[strID]==undefined) MediaTemp[strID]=false; else MediaTemp[strID]=!MediaTemp[strID];
 if(MediaTemp[strID]){
   if ( document.all ) {
           document.getElementById(strID).outerHTML = '

'
   }
   else
   {
           document.getElementById(strID).innerHTML = ''
   }

  document.images[strID+"_img"].src="images/mm_snd.gif"   
  document.getElementById(strID+"_text").innerHTML="在线播放" 
 }else{
  document.images[strID+"_img"].src="images/mm_snd_stop.gif"   
  document.getElementById(strID+"_text").innerHTML="关闭在线播放"
  switch(strType){
   case "swf":
    tmpstr='

';
    break;
   case "wma":
    tmpstr='
';
    break;
   case "wmv":
    tmpstr='
';
    break;
   case "rm":
    tmpstr='
'+
                '
'+'
';
    break;
   case "ra":
    tmpstr='
';
    break;
   case "qt":
    tmpstr='
';
  }
  document.getElementById(strID).innerHTML = tmpstr;
 }
  document.getElementById(strID+"_href").blur()
}

function Trim(TRIM_VALUE){
 if(TRIM_VALUE.length < 1){
  return"";
 }
 TRIM_VALUE = RTrim(TRIM_VALUE);
 TRIM_VALUE = LTrim(TRIM_VALUE);
 if(TRIM_VALUE==""){
  return "";
 }
 else{
  return TRIM_VALUE;
 }
} //End Function

function RTrim(VALUE){
 var w_space = String.fromCharCode(32);
 var v_length = VALUE.length;
 var strTemp = "";
 if(v_length < 0){
  return"";
 }
 var iTemp = v_length -1;

 while(iTemp > -1){
  if(VALUE.charAt(iTemp) == w_space){
  }
  else{
   strTemp = VALUE.substring(0,iTemp +1);
   break;
  }
  iTemp = iTemp-1;

 } //End While
 return strTemp;

} //End Function

function LTrim(VALUE){
 var w_space = String.fromCharCode(32);
 if(v_length < 1){
  return"";
 }
 var v_length = VALUE.length;
 var strTemp = "";
 var iTemp = 0;

 while(iTemp < v_length){
  if(VALUE.charAt(iTemp) == w_space){
   }
   else{
    strTemp = VALUE.substring(iTemp,v_length);
    break;
  }
  iTemp = iTemp + 1;
 } //End While
 return strTemp;
} //End Function


function CheckPost(){
  try{
 if (Trim(document.forms[0].title.value)=="") {
   alert("标题不能为空,请写日志标题!")
   document.forms[0].title.focus()
   return false
  }
 }
  catch(e){}

 

-六神源码网