我正在尝试处理一个 Jquery 代码,该代码可以找到页面src
中的所有标签,并用https://s3.amazonaws.com/abc<img>
替换和附加它,例如
<img src="/v/abx/templates/210/images/clear1x1.gif" width="5" height="5" alt="" />
应该替换为
<img src="https://s3.amazonaws.com/abc/v/abx/templates/210/images/clear1x1.gif" width="5" height="5" alt="" />
主要问题是它应该发生在页面加载
我有以下 Javascript 代码,但它不起作用
<!-- START: javascript to manipulate product photo URLs -->
<script type="text/javascript">
if(location.href.indexOf(‘/product_p/’) != -1) {
var ThisPhoto=document.getElementById('product_photo').src;
var ImgServer='https://s3.amazonaws.com/abc';
var ThisDomain=document.domain;
var NewImgSrc = ThisPhoto.replace(ThisDomain,ImgServer);
document.getElementById('product_photo').src=NewImgSrc;
}
</script>
<!-- END: javascript to manipulate product photo URLs -->