一段查找HTML中图片URL的JS代码+获取url里面的值
1.一段查找HTML中图片URL的JS
<script language="javascript">
function getimgsrc(htmlstr){
var reg=/<img.+?src=('|")?([^'"]+)('|")?(?:\s+|>)/gim;
var arr = [];
while(tem=reg.exec(htmlstr)){
arr.push(tem[2]);
}
return arr;
}
var htmlStr=" <P align=center> <FONT size=3> <IMG src='/include/eWebEditor/UploadFile/200941092128708.jpg' width=636 border=0>ddd <IMG style='WIDTH: 294px; HEIGHT: 245px' src=/include/eWebEditor/UploadFile/20094109234712.jpg' width=441 height=341 border=0> </P>";
var imgs=getimgsrc(htmlStr);
alert(imgs.join('\n'));
</script>
2.获取url里面的值
/*
* 获取url里面的realName
* url = "jms/imDown?groupId=100000003602&realName=1997430f-1c01-4db9-905b-26d074deb171.mp3&displayName=1415887733714.mp3";
* return {groupId: "100000003602", realName: "1997430f-1c01-4db9-905b-26d074deb171.mp3", displayName: "1415887733714.mp3"}
*/
getRealNameFromURL: function(url){
var isString = $.CRM.IM.isString(url);
if(isString){
var o = {};
url.replace(/(\w+)=([^&]+)/g,function(r,a,b){
o[a]=b;
});
return o.realName
}
}