js function for calculating character length
Copy Code code as follows:
function LEN (str) {
var i,sum=0;
for (i=0;i<str.length;i++) {
if ((Str.charcodeat (i) >=0) && (Str.charcodeat (i) <=255))
sum=sum+1;
Else
sum=sum+2;
}
return sum;
}
The JS function of the space before and after the character
Copy Code code as follows:
function TRIM (value) {return Value.replace (/^\s*/, '). Replace (/\s*$/, ');}
Picture Adaptive size function code
Copy Code code as follows:
function Imgautofit (imgobj,maxwidth,maxheight) {
var heightwidth;
var widthheight;
Heightwidth = Imgobj.offsetheight/imgobj.offsetwidth;
Widthheight = Imgobj.offsetwidth/imgobj.offsetheight;
if (imgobj.offsetwidth>maxwidth) {
Imgobj.width = MaxWidth;
Imgobj.height = Maxwidth*heightwidth;
}
if (imgobj.offsetheight>maxheight) {
Imgobj.height = MaxHeight;
Imgobj.width = Maxheight*widthheight;
}
}
function Checktagishave (s,t) {
var re=new RegExp ("<\\/?") +t+ "(?:(?: \ \s|\\/) (?: \ \n|.) *?)? > "," IG ");
var r=re.test (s);
Re=null;
return R;
}
function Imguploadfit () {
var u = document.getelementsbyname ("Imguploadname");
if (0==u.length) return;
for (Var i=0;i<u.length;i++) {
Imgautofit (u[i],560,560);
Imgautofit (u[i],320,320);
U[i].onclick = function () {window.open (THIS.SRC);}
U[i].style.cursor = "pointer";
U[i].title = "Click to see the original image";
}
}
function Inputcontent (theq,oldcontent,re,p) {
var o,oa=["Msgframeamend", "Pingjiaframe", "Tousuframe"];
For (o in OA) {
if ($ (oa[o])) {
Theq.editiframe (Oa[o]);
if ("Msgframeamend" ==oa[o]) settimeout (function () {$ (Oa[o)). ContentWindow.document.body.innerHTML = Oldcontent.replace (Re, "") +p[1];},100);
Return
}
}
}
function Checkcommon (n,v,t) {
var s = t? " Supplementary questions ":" Reply Content ";
var O=document.getelementbyid (n). Contentwindow;
if ("msgframereply" = = N) {
if (v = = "") {
Alert ("Please fill in" +s+ "!");
O.focus ();
return false;
}
}
if ("" "==v.replace (/<\/*) (?: IMG|P|PRE|BR) (?:(?: \ s|\/) (?: \ n|.) *?)? >|\s| /ig, "") &&checktagishave (V, "img")) {
Alert ("For pictures, please attach some descriptive text!") ");
O.focus ();
return false;
}
if (10000<len (v)) {
Alert (s+ "More than 5000 words limit!");
O.focus ();
return false;
}
return true;
}