1. Compress the picture proportionally
function Setimgsize () {varoutbox_w=imgbox.width (), Outbox_h=imgbox.height (); Imgbox.find ('img'). Each (function (index, EL) {varobj=$ ( This), Objh=obj.height (), OBJW=obj.width (); if((OBJH/OBJW) > (outbox_h/outbox_w)) {obj.css ({height:outbox_h+"px", Width: ((objw/OBJH) *outbox_h) +"px", MarginLeft: ((Outbox_w-((OBJW/OBJH) *outbox_h))/2)+"px"}); }Else{obj.css ({width:outbox_w+"px", Height: ((objh/OBJW) *outbox_w) +"px", MarginTop: ((Outbox_h-((OBJH/OBJW) *outbox_w))/2)+"px" }); } });
}
2. Parse the string parameters on the URL:
function getquerystring (parm) { var reg = new RegExp ("(^|&)" + parm + "= ([^&]*] (&|$)", "I"); var r = window.location.search.substr (1). Match (reg); if (r! = null) return unescape (r[2]); return null;}
Note: the Unescape () function (finds a sequence of characters in the form of%xx and%uxxxx (x for hexadecimal digits), decodes a sequence of characters with Unicode characters \u00xx and \uxxxx, and corresponds to escape () encoding), ECM Ascript V3 has removed the unescape () function from the standard and opposes its use, so it should be replaced with decodeURI () and decodeURIComponent ().
Note: Even if the value of the & connector, there is no relationship, can be encodeuricomponent transcoding into the form of%26, and the browser automatically splicing does not conflict, remember decodeURIComponent () decoding is good.
3, the common JS check
3.1 Mobile phone number check
/^ (0| | 17951)? ([0-9]| the [012356789]| - [678]| - [0-9]| - [up]) [0-9] {8}$/
3.2 Kanji Check
/^[a-za-z\u4e00-\u9fa5]+$/
JS Common functions Summary (not regularly updated)