计算字符长度的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;
}
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 《腾格尔 容中尔甲 亚东 高原三星 男人篇 3CD》[WAV/分轨][1GB]
- 命运圣契公测实测可用兑换码大全 命运圣契最新兑换码分享
- 黑神话悟空上品疾蝠精魄获取方法一览|上品疾蝠精魄收集攻略
- 《七龙珠电光炸裂!ZERO》GT角色预告片曝光,15位新角色登场
- [ABC]安娜-胆麦发烧女声[6N纯银镀膜][2016[低速原抓WAV+CUE]
- NewViennaOctetViennaWindSoloists-TheDeccaRecordings(2024)18CD[24-48][FLAC]-7
- 雨果唱片-三角琴《俄罗斯民间音乐系列-梁祝(中国名曲)》wav
- 《塞尔达传说:智慧的再现》新实机!无之世界介绍
- 任天堂公布《塞尔达传说》系列时间线:野炊与王泪独立在外
- 任天堂更新网络投稿规范:打击影响他人游戏体验行为
- 冼佩瑾.2024-女儿Daughter(EP)【杰威尔】【FLAC分轨】
- 黑豹乐队.1993-光芒之神【摇音晨【WAV+CUE】
- 曾轶可.2011-一只猫的旅行【天娱传媒】【WAV+CUE】
- 黑神话悟空上品狼刺客精魄获取方法一览|上品狼刺客精魄收集攻略
- 视觉小说《神椿市建设中REGENERATE》将于2025年2月20日发售