计算字符长度的js函数
复制代码 代码如下:
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函数
复制代码 代码如下:
function TRIM(value){return value.replace(/^\s*/,'').replace(/\s*$/,''); }
图片自适应大小函数代码
复制代码 代码如下:
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 = "点击看原图";
}
}
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?"补充提问":"回复内容";
var o=document.getElementById(n).contentWindow;
if("msgframereply" == n){
if(v == ""){
alert("请填写"+s+" !");
o.focus();
return false;
}
}
if(""==v.replace(/<\/*?(?:img|p|pre|br)(?:(?:\s|\/)(?:\n|.)*?)?>|\s| /ig,"")&&checkTagIsHave(v,"img")){
alert("针对图片,请附上一些说明性的文字!");
o.focus();
return false;
}
if(10000<LEN(v)){
alert(s+"超过5000字数限制 !");
o.focus();
return false;
}
return true;
}
javascript,函数
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 群星2013-青春缤纷辑压箱宝大公开3CD2[新加坡限量版][WAV整轨]
- 林育群.2013-BalladShow(日本版)【环球】【WAV+CUE】
- 陈加洛.1992-痛到感觉不到【宝丽金】【WAV+CUE】
- 群星.2023-宿命之敌电视剧原声带【韶愔音乐】【FLAC分轨】
- 東京事変-大発見[FLAC+CUE]
- 椎名林檎-三文ゴシップ[FLAC+CUE]
- 2024年08月04日
- 裘德《裘德「最后的水族馆」演唱会LIVE》[320K/MP3][228.89MB]
- 裘德《裘德「最后的水族馆」演唱会LIVE》[24bit 48kHz][FLAC/分轨][2.08G]
- 基因三重奏《如果你什么都不说 音乐会现场录音》[320K/MP3][145.37MB]
- 孟庭苇.1996-月亮说话(2020环球24KGOLD限量版)【上华】【WAV+CUE】
- 群星.1997-新艺宝优质音响系列·国语精选监听版【新艺宝】【WAV+CUE】
- 阿桑.2005-寂寞在唱歌(星外星引进版)【华研国际】【WAV+CUE】
- 基因三重奏《如果你什么都不说 音乐会现场录音》[FLAC/分轨][287.43MB]
- 蔡题谦《我爱你,却依然要看你走》[320K/MP3][88.65MB]