js中清除字符串中某个字符串
#create ydds
#date 2009-09-20
//remove src target
function removestrwithcomma(srcstr, targetstr){
var returnstr = '';
if (srcstr == null || srcstr == '' || srcstr == undefined) {
return returnstr;
}
else
if (srcstr.indexof(targetstr) == -1) {
return srcstr;
}
else {
var srcstrs = srcstr.split(',');
if (srcstrs.length == 1) {
returnstr = '';
}
else
if (srcstr.match(eval("/^" + targetstr + ".*/")) != null) {
returnstr = srcstr.replace(targetstr + ',', '');
}
else
if (srcstr.match(eval("/.*" + targetstr + "$/")) != null) {
returnstr = srcstr.replace(',' + targetstr, '');
}
else {
returnstr = srcstr.replace(',' + targetstr, '');
}
return returnstr;
}
}
var xmlhttplink;
function createxmllinkhttprequest(){
if (window.activexobject) {
xmlhttplink = new activexobject("microsoft.xmlhttp");
}
else
if (window.xmlhttprequest) {
xmlhttplink = new xmlhttprequest();
}
}
本文出自 “一灯” 博客