更新时间:2023-12-05 17:24:22
你的正则表达式是问题,你需要用斜杠包装它(否则解释器不知道它应该把它当作正则表达式):
Your regular expression is the problem, you need to wrap it in slashes (otherwise the interpreter has no clue that it should treat that as a regexp):
var allImg=document.getElementsByTagName("img"), i=0, img;
var pattern = /^http\:\/\/aff\.kooora\.com\/(.*)$/;
while (img = allImg[i++])
{
if (img.src.match(pattern)) {
img.src = img.src.replace(pattern, 'http://example.com/aff.kooora.com/$1');
}
}