前端屏蔽站外图片的js代码
<script type="text/javascript"> addEventListener('DOMContentLoaded', function (event) {undefined var imgs = document.querySelectorAll('.content img');//需要屏蔽图片的区域 var imgscount = imgs.length; for (let i = 0; i < imgscount; i++) { var imgsrc = imgs.item(i).src; if(imgsrc.indexOf("www.it333.cn") == -1){ imgs.item(i).src = 'https://www.it333.cn/notimg.gif'; } } }); </script>