当数据库中存储的地址为:
<A target=_blank href="/console/ewebeditor/uploadfile/2019.xls">公示.xls</A> 或者
<A target=_blank href="http://10.3.1.1/console/ewebeditor/uploadfile/2019.xls">公示.xls</A> 地址时
需要替换显示为:
<a target="_blank" href="/console/ewebeditor/uploadfile/20191119165512410.xls"
οnclick="javascript:window.open("http://10.16.10.1:8182/console/ewebeditor/uploadfile/2019.xls")">公示.xls</a>
页面写法:
<script>
setTimeout(function(){
var str=$("#fjcontent").html();
$("#fjcontent a").each(function(){
var href=$(this).attr('href');
if(href.indexOf('http://')==-1){
str=str.replace(href+"\"",href+"\" οnclick='javascript:window.open(\""+"http://10.16.10.1:8182"+href+"\")'");
}else{
str=str.replace(href+"\"",href+"\" οnclick='javascript:window.open(\""+href+"\")'");
}
$("#fjcontent").html(str);
});
},0);
</script>