全站图片src添加前缀JS方法
<script type="text/javascript">
window.onload=function(){
var imgs = document.getElementsByTagName('img');
for(var i = 0;imgs[i];i++){
var thttp = imgs[i].getAttribute('src').indexOf("http");
var tok = imgs[i].getAttribute('src').indexOf("//");
if(thttp == -1 || tok == -1) {imgs[i].setAttribute('src', 'https://www.yingzi.biz/' + (imgs[i].getAttribute('src') || ''));}
}
}
一定用setAttribute,getAttribute,切忌莫直接用imgs[i].src = 'http//aaa/' + imgs[i].src