JS functions that calculate the character Length
CopyCode The Code is 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;
}
JS functions that remove spaces before and after charactersCopy codeThe Code is as follows: function trim (value) {return value. Replace (/^ \ s */, ''). Replace (/\ s * $ /,'');}
Image Adaptive size function code
Copy codeThe Code is 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 view the source 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()[((oaoaoa.contentdoc Doc ument. Body. innerhtml = oldcontent. Replace (Re, "") + P [1];}, 100 );
Return;
}
}
}
function checkcommon (n, V, T) {
var S = t? "Supplemental question": "Reply content";
var o = document. getelementbyid (n ). contentWindow;
If ("msgframereply" = N) {
If (V = "") {
alert ("enter" + S + "! ");
O. focus ();
return false;
}< BR >}< br> 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;
}< br> If (10000 alert (S + "exceeds 5000 words limit! ");
O. Focus ();
return false;
}< br> return true;
}